views:

20

answers:

1

If my HTML form contains two form inputs (input1 and input2), I could access them like this:

@RequestMapping(value = "/foo", method = RequestMethod.POST)
public String foo(HttpServletRequest request, ModelMap modelMap,
    @RequestParam(value = "input1") String input1,
    @RequestParam(value = "input2") String input2)
{
            log.write("input1=" + input1);
            log.write("input2=" + input2);

    return "redirect:/foo/";
}

But what if I have other form elements on the HTML page that I don't know about?

How can I print out the values of form elements that I have not declared in the action method with a @RequestParam annotation?

+2  A: 

using HttpServletRequest - request.getParameterNames() this will get all the submitted parameters.

Bozho