JavaWeb
javaWeb Servlet转发中文乱码解决
这里使用的是Eclipse with javaEE 写的项目(与MyEclipse基本无异)
- 将数据库编码类型修改为UTF-8
huyunfei
本文链接:https://blog.****.net/huyunfei/article/details/100916592 - jsp页面修改为UTF编码
- Servlet中设置
request.setCharacterEncoding(“utf-8”);
response.setCharacterEncoding(“utf-8”);
response.setContentType(“text/text;charset=utf-8”); - 删除自动生成的 response.getWriter().append("Served at: ").append(request.getContextPath());
在jsp页面设置编码方式
设置Servlet编码
(这里是使用doGet方式)如果是使用的doGet方式需要在doGet方法里写
处理完成,中文乱码解决