struts2中文乱码
来源:互联网 发布:excel数据有效性没了 编辑:程序博客网 时间:2024/05/16 09:14
以前在使用webwork2.2.6,今天换了struts2试试,版本struts2.1.6。根据官方包下给的例子配置action拦截器时总是对中文不能很好的支持。
官方web.xml配置如下
或者使用官方的另一配置
测试的其他环境编码: tomcat5.5 编码utf-8、测试页面编码
form表单:
使用以上配置在进行表单提交时总是对中文显示乱码,当将method="post"该为method="get"时该问题不存在。
google了下,说要设置struts.locale和struts.i18n.encoding,但设置后并未有任何效果。该设置在struts.xml和struts.properties中均做过测试,未通过。也有说要设置org.springframework.web.filter.CharacterEncodingFilter
(详见:http://ywlqi.javaeye.com/blog/323589),该方式未经测试。
想到在使用webwork中并未进行如此配置,但均不会出现问题。考虑到struts2和webwork的关系,遂将web.xml 中的action拦击改为
同时不用设置struts.locale和struts.i18n.encoding,问题解决。
另,如系统使用的是GBK或是其他编码,除了在页面、服务器(tomcat)中设置相应的编码外,还要在struts.xml中增加 <constant name="struts.i18n.encoding " value="系统编码" />或是在struts.properties中添加struts.i18n.encoding = 系统编码。如果没搞错的话struts2.1.6默认是对utf-8支持的。
至于是什么问题引起该中问题,目前尚不清楚。待后续继续查找了。(ps:应该是org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter的问题)
注:在运行struts2.1.6的struts2-showcase-2.1.6例子中personManamger中,创建一个中文用户时系统出现乱码,是否可以推断官方在struts2.1.6包携带的例子中并未解决中文编码问题。
- struts2中文乱码解决方法
- Struts2 中文乱码问题解决
- Struts2中文乱码解决方法
- Struts2中文乱码解决方法
- struts2中文乱码解决方法
- struts2中文乱码
- struts2中文乱码解决方法
- Struts2中文乱码解决办法
- struts2中文乱码解决方法
- Struts2中文乱码解决方法
- struts2 中文乱码解决办法
- struts2解决中文乱码
- struts2中文乱码解决方法
- struts2中文乱码问题
- struts2中文乱码解决
- Struts2 中文乱码问题解决
- struts2中文乱码解决方法
- struts2中文乱码解决方法
- 小问题烦死人,解决了------------GetFieldValue 报错:无效的描述符索引
- Object-C 入门教程
- spring2.5 jdbcTemplate学习笔记
- 队列的定义及基本运算
- Enterprise Resource Planning
- struts2中文乱码
- hibernate3.1 项目开发汇总
- 让页面控件响应 回车
- 端口
- BOM断阶原则
- 使用两个路由器共享上网的接法
- 维度浅尝辄止
- C# 获得当前目录和执行目录的一些方法
- ie6失真问题