像以前一样,结果在后台就是乱码。最后的解决之道是:
原文链接:https://www.f2er.com/ajax/164070.html
原来,以前是在doGet中接收:
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String message=request.getParameter("msg");
message=new String(message.getBytes("ISO-8859-1"),"
UTF-8");
我这个是在doPost中接收:
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String message=request.getParameter("msg");
message=new String(message.getBytes("ISO-8859-1"),"
gb2312");
第一次看到这样的,记下来了