Request
- 通用方法(适用于GET/POST)
将从request(域)中取出的信息(乱码)转为二进制String para = request.getParameter([name]); byte[] bytes = para.getBytes("ISO8859-1");//编码格式 String str = new String(bytes,"UTF-8");
再将二级制用UTF-8转为字符串
2.设置请求编码(只适用于POST)request.setCharacterEncoding("UTF-8");
Response
response.setContentType("text/html;charset=utf-8");
是不是发现和HTML很像?