2017-09-13 51 views
0

这让同名所有的HTML的输入值的servlet的HTML如何通过ArrayList的

<input type="hidden" value="Brand" name="labelValue" /> 
<input type="hidden" value="model" name="labelValue" /> 

这是Servlet部分

String values=request.getParameter("labelValue"); 

如何让这一个ArrayList并且输入计数正在变化

+0

改为使用'String [] request.getParameterValues(String)'方法。 http://docs.oracle.com/javaee/7/api/javax/servlet/ServletRequest.html#getParameterValues-java.lang.String- – CollinD

回答

2
// Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. 
String[] values=req.getParameterValues("labelValue"); 

// Convert String array to arrayList. You can assign this to variable and use. 
new ArrayList<String>(Arrays.asList(values));