weixin_42502453
weixin_42502453
2012-12-07 17:35

struts2 乱码问题

  • it技术
  • 互联网问答
  • IT行业问题
  • 编程语言问答
  • 计算机技术

请教下,struts2 的乱码问题,

1、jsp页面设置的编码是utf-8
[code=java]<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>[/code]
2、struts.xml

[code=java]
[/code]
3、在web.xml中加了filter
[code=java] public void doFilter(ServletRequest req, ServletResponse resp,
FilterChain arg2) throws IOException, ServletException {
// TODO Auto-generated method stub
HttpServletResponse response = (HttpServletResponse) resp;
HttpServletRequest request=(HttpServletRequest)req;
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
arg2.doFilter(request, response);
}
[/code]
4、mysql数据库中
[code=java][mysql]

default-character-set=utf8

character-set-server=utf8[/code]
5、tomcat 的 service.xml中
[code=java] connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>[/code]
6、在console接收参数时后台打印的也正常,包括构造sql语句的输出也是正常的,但是在struts的调试模式还是存在乱码,,崩溃中!!!!!!
[img=http://img.my.csdn.net/uploads/201212/07/1354871421_9159.png][/img]

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换