1.这是我的表单代码:
<form method="GET" action="Add">
first-name: <input type="text" name="first-name" value=""/><br/>
last-name: <input type="text" name="last-name" value=""/><br/>
email-id: <input type="text" name="email" value=""/><br/>
<input type="submit" name="submit" value="join now"/><br/>
</form>
2.这里是servlet片段:
Enumeration<String> en=request.getParameterNames();
while(en.hasMoreElements()){
String param=en.nextElement();
PrintWriter pw=response.getWriter();
pw.print(param);
pw.println(request.getParameter(param));
这是输出:
first-namevishal
emaildrunkendeathison@gmail.com
submitjoin now
last-nameanand
为什么不按顺序提取?在 first-name last-name 之后必须来,然后 email 和 submit 必须来,对吗??