为了解决form提交到action中的中文参数乱码问题。
[color=red]根据页面编码进行设置,如果所有页面使用UTF-8就使用UFT-8,如果GBK,就设置GBK。[/color]
1.在struts2-core-2.0.0-SNAPSHOT.jar包中路径为struts2-core-2.0.6\org\apache \struts2有一个default.properties 文件,把struts.i18n.encoding=UTF-8改为struts.i18n.encoding=GBK
2.在struts.properties文件中设置struts.i18n.encoding=GBK。
3.或者在struts.xml文件内添加常量:
<constant name="struts.i18n.encoding" value="GBK"/>
[color=red]根据页面编码进行设置,如果所有页面使用UTF-8就使用UFT-8,如果GBK,就设置GBK。[/color]
1.在struts2-core-2.0.0-SNAPSHOT.jar包中路径为struts2-core-2.0.6\org\apache \struts2有一个default.properties 文件,把struts.i18n.encoding=UTF-8改为struts.i18n.encoding=GBK
2.在struts.properties文件中设置struts.i18n.encoding=GBK。
3.或者在struts.xml文件内添加常量:
<constant name="struts.i18n.encoding" value="GBK"/>
本文介绍了解决Struts2框架中form提交时出现的中文参数乱码问题的方法。通过修改struts2配置文件中的编码设置,如struts.i18n.encoding属性,可以确保中文字符正确传输。
1436

被折叠的 条评论
为什么被折叠?



