Question

When once form is submitted successfully....

but When I click on "BACK" button and trying submit same form its gives me an error enter image description here

Source:

<g:form action="addData" name="addValues" controller="emp" method="Post">
</g:form>

Controller Source:-

def editProfile (Long id,Long version){
        withForm {
        // code
            }.invalidToken {
            response.status = 405

        }
    }
Was it helpful?

Solution

Its hard to infer the cause of the error with what you have posted. However, you asked about how to prevent a page from resubmitting in Grails. Take a look at documentation. Grails has a build in support for that. Basically you define a form with a token and using withForm you will check if the token still is valid or not.

<g:form useToken="true" ...>

/

withForm {
   // good request
}.invalidToken {
   // bad request
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top