现在的位置: 首页 > 综合 > 正文

struts 中文乱码问题

2013年09月10日 ⁄ 综合 ⁄ 共 413字 ⁄ 字号 评论关闭

再用struts 开发时经常遇到中文乱码问题

(1)页面显示乱码

修改页面的"UTF-8"

(2)传递参数乱码

修改服务器的Sever.xml文件

-->
    <Connector port="8080" protocol="HTTP/1.1"
               maxThreads="150" connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8" />

编写过滤器

新增加实现implements Filter接口的类

request.setCharacterEncoding("utf-8");
  chain.doFilter(request, response);

修改web.xml文件

 

(3)国际化中文乱码

工具:Eclipse ResourceBundle Editor

修改ApplicationResources.properties文件

抱歉!评论已关闭.