Servlet - Chinese garbled data request

1. String data is re-encoded into

  String username = request.getParameter("username");

  username = new String(username.getBytes("iso8859-1"), "utf-8");

2. Use common configuration

  GET submission:

    1. Modify the Tomcat conf server.xml file in the directory, the increase in the property useBodyEncodingForURI Connector tag = "true"

    2. request.setCharacterEncoding("utf-8");

  POST submission: 

    Added directly request.setCharacterEncoding ( "utf-8");

Guess you like

Origin www.cnblogs.com/mpci/p/12613846.html