Chinese garbled characters appear in requests and responses

(1) Handle the garbled characters of the response:

response.setContentType("text/html;charset=UTF-8");

(2) Garbled characters when processing requests (there are two methods of request: POST method and GET method)
POST method request:

request.setCharacterEncoding("UTF-8");

GET method request:

name=new String(name.getBytes("ISO-8859-1"),"UTF-8");

Guess you like

Origin blog.csdn.net/OYMNCHR/article/details/116562262