日期:2014-05-17  浏览次数:20627 次

STRUTS2.1传入中文参数给ACTION乱码问题
通过
href="TurnToSubjectPage.action?pageNum=1&title=<s:property value="title"/>"
的方式传递中文(title参数)给ACTION,在ACITON中获得的title值是乱码,
请问如何解决?

页面编码为
<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>

请问如何解决。

------解决方案--------------------
struts2的配置文件下: <constant name="struts.i18n.encoding" value="GBK"></constant>
------解决方案--------------------
引起乱码的原因可能有很多种
楼上的回答可以解决一部分问题
还有就是tomcat connector配置也会引起乱码问题
<Connector .............. URLEncoding="GBK"/>
这样可以解决
另外就是通过传递带编码格式的参数来解决
String name = new String("小明","GBK");