0 Replies Latest reply on Oct 18, 2018 12:52 AM by Ben Gao

    url data without encodeURIComponent occurred messy code

    Ben Gao Novice

      create a servlet just like: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

      // TODO Auto-generated method stub

      name =new String(request.getParameter("name").getBytes("utf-8"));

      System.out.println(name);

      System.out.println(request.getParameter("name"));

      response.getWriter().append("Served at: ").append(request.getContextPath());

      }

      then use

      curl --header "Content-Type:application/x-www-form-urlencoded;charset=utf-8" -d "name=中文" http://1et/Test1:8080/sync-servle then getParameter messy code

      I find someone like me :https://stackoverflow.com/questions/43085811/ajax-post-to-jboss-eap-7-without-encodeuricomponent-occurred-messy-code

       

      io.undertow.server.handlers.form.FormEncodedDataDefinition.FormEncodedDataParser.doParse(final StreamSourceChannel channel),

      it handled like this:

      buffer.clear();

      int c = channel.read(buffer);

      if (c > 0) { buffer.flip();

      while (buffer.hasRemaining()) {

      byte n = buffer.get();

      builder.append((char) n);

      //the problem occurred here,[a][b][c] would be changed to [0][a][0][b][0][c]