Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7071

HttpServletRequest.getParameter only get String from query not both posted form data

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.7
    • Fix Version/s: 3.0.13, 3.1.11, 3.2.0
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      The http request:
      POST /dubbott-demo-provider/v1.0/users/beanparam HTTP/1.1
      HOST: localhost:8080
      accept: text/plain
      content-type: application/x-www-form-urlencoded
      content-length: 12

      pageIndex=99

      The resource method returns null:

          public String beanParam(@Context HttpServletRequest req, String ak) {
              String pageIndex = req.getParameter("pageIndex")    
              return pageIndex;
          }
      

      From the servlet 3.1 API doc:
      String javax.servlet.ServletRequest.getParameter(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.

      if we add below servlet filter:

      	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
      	        System.out.println(request.getParameter("pageIndex") );
      		chain.doFilter(request, response);
      	}
      

      The output is "99" the response is the same "99".

      As a conclusion the CXF HttpServletRequest doesn't comply the Servlet 3.1 API Spec.

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              nbqyqx@163.com Neal Hu
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: