This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

password change form and controller

I would like to create a form permitting users to change their password.

With the @RequestMapping(value = "/change-pass*", method = RequestMethod.POST), i get this error :
Request method 'GET' not supported

With the @RequestMapping(value = "/change-pass*", method = RequestMethod.GET), i get another :
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'password' available as request attribute.

Please use [ code][/code ] tags when posting code, that way we can actually read your code ...

Next don't extend abstractcontroller and use @Controller use either one not both. Also make your form a POST (the initial error indicates that you are only doing a GET!). Also your controller is pretty useless as you expect your newly created model to already contain some values?! In short I really don't get your controller.

Comment

Please use [ code][/code ] tags when posting code, that way we can actually read your code ...

Next don't extend abstractcontroller and use @Controller use either one not both. Also make your form a POST (the initial error indicates that you are only doing a GET!). Also your controller is pretty useless as you expect your newly created model to already contain some values?! In short I really don't get your controller.

Thanks for advice but i didn't get where to put <code></code> tags.

i added the <form:form commandName="change-pass" method="post" action="change-pas"> to the jsp
and got the same error

then i removed the @Controller from the controller class and now got the 404 error

Comment

Maybe i could ask another way...here is my code to display informations of the user's account. Now it works well but i need to update changed data on user's click on the button register. What i have to do ?
Is the AbstractController the good class to extend or i better use SimpleFormController ?

Maybe i could ask another way...here is my code to display informations of the user's account. Now it works well but i need to update changed data on user's click on the button register. What i have to do ?
Is the AbstractController the good class to extend or i better use SimpleFormController ?

Have you actually read my post?! Don't mix Controller and @Controller which is what you are currently doing, as mentioned before don't do that..

I strongly suggest you read the reference guide on how to write form based @Controllers.

Comment

Have you actually read my post?! Don't mix Controller and @Controller which is what you are currently doing, as mentioned before don't do that..

I strongly suggest you read the reference guide on how to write form based @Controllers.

Hello,

yes i read your post and removed the @controller then got another error.
Now it works well with the @controller and extend AbstractController at the same time.
i can add data to the model and display them.
I just don't know what to do to get changed data back from the model to update the database.
I have read many documents about how to use spring mvc but still don't get it.

Comment

Hello,
i tried your code and that's what i got (for the lastname field for example) :

org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'lastname' of bean class [com.altran.emi.business.user.User]: Bean property 'lastname' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:707)

I'm starting to get the feeling that I'm having to do your job and you are just copy/pasting what is written here. If it doesn't work you are copy pasting the errors back again, sit back and wait for a solution.

I strongly suggest you read the reference guide, take a look at the sample application(s) to get an understanding on how it works.

Also when posting code use [ code][/code ] tags that way it remains readable!!!

But here is the answer in short.

lastname = lastName
firstname = firstName

I suggest a read of the JavaBeans specification and how properties work.

Comment

I tried your code and i got this error:
org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'lastname' of bean class [com.altran.emi.business.user.User]: Bean property 'lastname' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:707)

The code I post is to give you an idea but from what you postback I get the impression you are just copy/pasting without understanding. Your last post was at least due to this because you did an almost one on one copy at least for the names.

Your property is named lastName and not lastname and as such the error is simply in your form tag.

I only ask that before you post here you did at least some investigation yourself and try to understand how things work.