How can you print out the values of undeclared HTML form values from a Spring (3) controller action method?
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(HttpSer开发者_C百科vletRequest 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?
using HttpServletRequest
- request.getParameterNames()
this will get all the submitted parameters.
精彩评论