views:

15

answers:

1

I have a controller that a form posts to:

 @RequestMapping(value = "/formtest", method = RequestMethod.POST)
    public ModelAndView HandleFormPost()
    {
        ModelAndView mv = new ModelAndView("posttest");



        return mv;
    }

What are my options in retrieving the data from the form?

In asp.net I would just do:

Request.Form["key"] or Request["key"]

or I could use a parameter in my action FormCollection and then just do:

form["key"]

I am using spring MVC (version 3), what are my options?

+2  A: 

You could do any of the following:

public ModelAndView handleFormPost(WebRequest request) {
   request.getParameter("key");
}

or

public ModelAndView handleFormPost(@RequestParam String key) {

}

There are many other options, but these two are the easiest.

A @RequestMapping-annotated method can take a wide variety of different arguments (you just add them to the method and Spring will supply them), and can return a wide variety of different return types. The options are listed here.

skaffman
thanks! so a requestparam is either querystring or form value?
Blankman
you're still thinking in ASP :)
skaffman
was that an answer? now i'm confused hehe. I need a Response.End and also!
Blankman