struts2 action 接收中文乱码

问题描述:
Action中有某一属性,并设有响应的getter/setter方法,前台提交中文数据时Action接收乱码。
解决方案:
在struts.xml中加入
<constant name="struts.i18n.encoding" value="UTF-8"></constant>

然后打开tomcat目录下conf文件夹下的server.xml文件,找到
<Connector port="8080"  protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

在其中添加
URIEncoding="UTF-8"
useBodyEncodingForURI="true"

最后在jsp页面一定要注意编码格式和上面的一致
charset=utf-8

重启tomcat,
OVER

猜你喜欢

转载自wangankang.iteye.com/blog/1683852