这个不是优先的问题, 是你的请求方法的问题, 你的请求方法是 get 就用 URL上的参数, 如果你的请求方法是post,  就会用postData中的参数

解决方案 »

  1.   

    Lumia10200 
    说的不正确: 我是用的就是POST方法提交数据的。而且后台断点后,是能看到 operationFlag 数组的,且长度是3.
      

  2.   

    request.getParameter只能取出一个的
      

  3.   

    我主要问题是:
    为什么 url中的参数优先于 postData中的参数??有什么依据可以参考? 
      

  4.   

    刚BAIDU了一下,搜索到一个相关西信息:
    http://zhidao.baidu.com/link?url=OJ4Mlx_Mwyu_Ps1uhahXja2kMvsimplI72qaYaatv8ldqfSbxzquSZCZ0zqEcGYbuLNV9NfE5EoqXrvOcCmtv_ Request从几个集合取数据是有顺序的,从前到后的顺序依次是 QueryString,Form,最后是ServerVariables。Request对象按照这样的顺序依次搜索这几个集合中的变量,如果有符合的就中止,后面的就不管了。当然上面给的例子像是 ASP.NET ,但测试结果符合 servlet 获得结果相同。 
      

  5.   


    getParameter
    java.lang.String getParameter(java.lang.String name)Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data. 
    You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String). If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues. If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method. 
    Servlet API -ONLINE 上其实讲得已经很清楚了。只是总用BAI-DU,忽略了API。
    从上文中可以看出,(If the parameter data was sent in the request body, such as occurs with an HTTP POST request) ,servlet 推荐使用 getInputStream()or getReader()  来解决 多个重名参数(有的在QueryString,有的在 POST-DATA),如何获得POST-DATA中的同名参数的问题。由此判断,ServletRequest在 多个重名参数(有点在QueryString,有的在 POST-DATA)这种情形下,Request.getParameter() 是优先获得 QueryString中的参数的。
      

  6.   

    URL中的GET传参在tomcat,weblogic等应用服务器中通常被解析为queryString,getParameter都是取的这里面的值
    如果是post传参,默认会把post里面key=value也放到queryString中,因此request.getParameter取的是一样的效果
    如果是二者中有重名参数,肯定会有优先级的问题
      

  7.   

    提交表单的时候是可以提交多个相同名称的参数的,比如一个表单中可以提交多个 <input name = 'name' />这样的参数,在后台的时候就应该使用 String[] names  = request.getParameterValues("name"); 这样来获取相同的多个值 。楼主这样提交参数实质就是提交了表单中重名的参数了。