Its fun writing code!
Retrieve post data in Spring MVC?
Spring MVC 3.0 get post values into action. I have shown a simple example below:
<form method="post" action="validate">
login <input type="text" name="name"/>
password <input type="text" name="password"/>
<input type="submit"/>
</form>
Now, points comes how to retrieve these posted values.
@RequestMapping(value="validate", method = RequestMethod.POST)
public String validate(@RequestParam("name") String name,
@RequestParam("password") String password) {
if (!password.isEmpty()) {
return "dashboard/index";
}
return "redirect:/invaliduser";
}
