Grails form submit reasons 404

I created a very simple user registration form

<g:form name="signupForm" url="[controller:'users', action:'signup']"> <g:textField name="username" placeholder="Username" /> <g:passwordField name="password" placeholder="Password" /> <g:textField name="email" placeholder="Email" /> <g:actionSubmit class="right" value="Signup" action="update" /> </g:form> 

When I click the submit button, I get 404 error The requested resource is not available. However, if I go to the same URL manually (or even just select the address bar on the 404 error page and press the enter key), then it will work!

My controller looks like this, it is very simple.

 class UsersController { def signup() { render "Hello World" } } 

Sorry if this is a question with noob, but I looked through the Grails docs and can't figure out why this is happening. Any help is greatly appreciated. Thanks.

+4
source share
1 answer

In g: actionSubmit there is an action = "update" parameter that will push it to update the defs UserController, which is not there, so it will throw 404.

You can delete the action = "update" or add this action to the controller.

http://grails.org/doc/latest/ref/Tags/actionSubmit.html

There is also g: submitButton, which you can use instead.

http://grails.org/doc/latest/ref/Tags/submitButton.html

+5
source

Source: https://habr.com/ru/post/1445327/


All Articles