首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

struts2中redirect传中文参数乱码有关问题

2012-11-09 
struts2中redirect传中文参数乱码问题今天在开发过程中遇到一个乱码问题,记录一下:在struts2中配置跳转,用

struts2中redirect传中文参数乱码问题

今天在开发过程中遇到一个乱码问题,记录一下:

在struts2中配置跳转,用type="redirect",带中文参数成了乱码。

?

按以下方法解决此问题:

?

首先tomcat的配置文件中要配置编码:

server.xml
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8" />

?

其次

将 <result name="xx" type="redirect">xxxxxxxxxx?parameter=${parameter}</result>

?

改为:

<result name="xx" type="redirect">
? <param name="location">xxxxxxxx</param>
? <param name="parameter">${parameter}</param>
</result>

?

?

ps:

刚修改了没注意,过了几天发现这种传参方式抛出个异常


Caught OgnlException while setting property 'message' on type 'org.apache.struts2.dispatcher.ServletRedirectResult'.
Caught OgnlException while setting property 'message' on type 'org.apache.struts2.dispatcher.ServletRedirectResult'. - Class: ognl.ObjectPropertyAccessor
File: ObjectPropertyAccessor.java
Method: setProperty
Line: 166 - ognl/ObjectPropertyAccessor.java:166:-1

?

在网上查了一下,原因可能是struts2的bug,没有找到解决的办法

?

热点排行