1.POST方式
request.setCharacterEncoding("UTF-8");
2.GET方式
String str = request.getParameter("name(html的name)");
1.先对乱码数据进行编码,转化为字节数据 2.字节数组解码
byte[] bytes = str.getBytes(StandardCharsets.ISO_8859_1);
str = new String(bytes,StandardCharsets.UTF_8);
8及以上版本不需要以上代码即可正常转化