如何将具有相同名称的输入值提取到servlet中? [英] How do i extract input values with the same name into a servlet?
本文介绍了如何将具有相同名称的输入值提取到servlet中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含各种productID值的表格.它们包含在输入文本中,不同的值都具有相同的名称.
I have a form that contains various productID values. They are contained in an input text, with different values all having the same name.
<%
ListIterator ul2 = myCartList3.listIterator();
while(ul2.hasNext()){
ShoppingCart myCart2 = new ShoppingCart();
myCart2 = (ShoppingCart)ul2.next();
%>
<input type="text" value="<%=myCart2.getProductID() %>" name="productID" size="3" />
<%
}
%>
提交表单后,它将转到servlet.通常我会使用request.getParameter
,但是它只显示一个属性.如何检索具有相同名称的多个属性?
When the form is submitted, it goes to the servlet. Usually I'd use request.getParameter
but it only displays one attribute. How do I retrieve multiple attributes with the same name?
推荐答案
您可以使用
String[] productIDs= request.getParameterValues("productID");
这篇关于如何将具有相同名称的输入值提取到servlet中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文