Java – spring MVC passes a list of values from the JSP page to the controller
•
Java
If I have HTML in < form >, like this:
<input type="text" value="someValue1" name="myValues"/> <input type="text" value="someValue2" name="myValues"/> <input type="text" value="someValue3" name="myValues"/> <input type="text" value="someValue4" name="myValues"/>
I know that in the servlet, I can get values using the following methods:
String[] values = request.getParameterValues("myValues");
How to use spring MVC to do similar things?
Solution
Parameters are passed as parameters to methods bound to the controller
@RequestMapping(value = "/foo",method = RequestMethod.POST) // or GET public String foo(@RequestParam("myValues") String[] myValues) { // Processing return "view"; }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码