- 页面乱码,首先看下网页源码,注意 content-type=’text/html’;charset=“utf-8”;
- servlet里面设置request.setCharacterEncoding("utf-8");
- 如果是向页面写内容,需要设置response.setCharacterEncoding("utf-8");
注意写的地方:(如果在setContentType下面,也会出现乱码)
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
- 在JSP页面传递参数时,所以页面编码格式要相同,否则在传递中文等字符时会出现乱码问题。request.setCharacterEncoding方法就是设定参数的编码格式。在URL中有参数传递时,需要对这些参数进行编码处理。在JS中,通过调用encodeURL或者encodeURLConponent实现编码,在JSP脚本里,通过方法URLEncoder.encode实现转码。
- 工程是否是utf-8
还有其他的问题,不断更新中。。。