日期:2014-05-18  浏览次数:20730 次

问Enumeration输出顺序的问题
小弟在学习时发现:
<html>
<head>
<title> show   form </title>
</head>
<body>
<h2>
These   are   submitted   by   the   form:
</h2>
<%
      //得到所有的参数名称
      java.util.Enumeration   e=request.getParameterNames();
      //对所有参数进行循环
      while(e.hasMoreElements())  
      {
            //得到参数名
            String   name=(String)e.nextElement();
            //得到这个参数的所有值
            String[]   value=request.getParameterValues(name);
            //输出参数名
            out.print( " <p> ");
            out.print( " <h3> "+name+ ": ");
            //对一个参数所有的值进行循环
            for(int   i=0;i <value.length;i++)  
            {
                  //输出一个参数值
                  out.print(value[i]);
                  if(i!=value.length-1)
                  {out.print( ", ");}
            }
            out.print( " </h3> </p> ");
      }
%>
</body>
</html>      
这个输出后的顺序跟接收原表单数据的顺序不大一样.我这里的结果跟教程上的输出顺序也不一样.不知道是怎么回事.
大虾指点跟什么有关?
表单是:
<html>
<head>
<title> input   something   in   form </title>
</head>
<body>
<h2>
Input   something   in   form.
</h2>
<form   name= "fm "   action= "04_02.jsp "   method= "post ">
<p> input   text:
<input   type= "text "   name= "username ">
</p>
<p> input   password:
<input   type= "password "   name= "password ">
</p>
<p> input   textarea:
<textarea   name= "textarea "   rows= "5 "   cols= "50 ">
          Hello,This   is   a   textarea.
</textarea>          
</p>
<p> input   file:
<input   type= "file "   name= "myfile ">
</p>
<p> <center>
<input   type= "submit "   value= "提交 ">
</center> </p>
</body>
</html>

我的输出顺序是:
textarea:


password:


myfile:


username:


------解决方案--------------------
QueryString和content部分
用getQueryString 和getInputStream得到吧
剩下的就是xxx=xxx&yyy=yyy这些的解析了
还有urlencode的问题