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";
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>