Struts2 中文乱码
来源:互联网 发布:淘宝行业数据 编辑:程序博客网 时间:2024/05/18 03:03
环境: struts包版本:struts-core-2.1.6
filter配置:
JSP页面均已配置:contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
struts.xml 无论是否加入: <constant name="struts.i18n.encoding" value="GBK" />
过程:通过index页面上form表单向result页面发送中文字符请求
结果:
method="GET" 乱码 无论是form中设置method还是浏览器输入
method="POST" 正确中文
总结:在web.xml中,将struts2配置为org.apache.struts2.dispatcher.FilterDispatcher时,post请求均可很好的自动解决中文乱码问题,get一律报错(在不借助其他方法进行手动重编码的情况下)
在web.xml中,将struts2配置为org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter时,无论如何中文均报BUG,据官方解释此为BUG, struts 2.1.7后进行了修复
结论: 在2.1.7之前,结果中文乱码问题,最好自行编写CharactorEncodingFilter进行编码。
若试图使用上述中的FilterDispatcher解决中文问题,则会连带产生由于Filter版本不同而带来的多种问题,其一便是自定义Action中利用ActionContext.getContext.get("request")引发空指针的问题
相关资源:http://topic.csdn.net/u/20081029/14/ea380205-ae9a-4ad0-9a7d-5ab1b09a1908.html
- struts2中文乱码解决方法
- Struts2 中文乱码问题解决
- Struts2中文乱码解决方法
- Struts2中文乱码解决方法
- struts2中文乱码解决方法
- struts2中文乱码
- struts2中文乱码解决方法
- Struts2中文乱码解决办法
- struts2中文乱码解决方法
- Struts2中文乱码解决方法
- struts2 中文乱码解决办法
- struts2解决中文乱码
- struts2中文乱码解决方法
- struts2中文乱码问题
- struts2中文乱码解决
- Struts2 中文乱码问题解决
- struts2中文乱码解决方法
- struts2中文乱码解决方法
- 背单词方法
- linux下挂载新的虚拟磁盘
- 导出符合条件的mysql记录
- 上海High-level Synthesis Software Engineer(高层次/系统综合软件工程师)
- 费马小定理 素数判定 蒙哥马利算法
- Struts2 中文乱码
- android (style&theme)
- BigDecimal,Double精度问题
- struts2整合json使用
- 跟我一起写 Makefile
- 《乔布斯传》今日(10/24)10时05分全球同步首发
- cookie
- C# Conditional debug
- c++编译模式