客戶機代碼檢測下拉列表的值是很簡單:問題與服務器(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