How to get a form value in a controller

You can get single value by @RequestParam and total form values by @ModelAttribute.

Here is code for single field-

 @RequestMapping(value="/forgotpassword", method=RequestMethod.POST)
 public String getPassword(@RequestParam("j_username") String username) {
        //your code...
    }

And if you have more values in form and want to get all as a single object- Use @ModelAttribute with spring form tag.


You can use @RequestParam like this:

@RequestMapping(value="/forgotpassword", method=RequestMethod.POST)
public String recoverPass(@RequestParam("j_username") String username) {
    //do smthin
}