客户机代码检测下拉列表的值是很简单:问题与服务器(servlet的)侧
<form action="DDServlet" method="post">
<input type="text" name="customerText">
<select id="customer">
<option name="customerOption" value="3"> Tom </option>
<option name="customerOption" value="2"> Harry </option>
</select>
<input type="submit" value="send">
</form>
这里是关于Servlet
Enumeration paramNames = request.getParameterNames();
while(paramNames.hasMoreElements()){
String paramName = (String)paramNames.nextElement(); //get the next element
System.out.println(paramName);
}
当我打印的代码我只看到,customerText
,但不是customerOption
。任何想法为什么家伙?我希望,如果我在选项中选择Tom
,一旦我提出,在我的servlet我应该能够做到这一点:String paramValues[] = request.getParameterValues(paramName);
并取回的3
+1,参数名称将为customerOption,而不是客户。我通常保持我的id和姓名字段相同,但它并不重要。 – 2010-03-31 02:11:49
非常感谢 – 2010-03-31 02:12:36