spring mvc中redirect带中文参数怎么转换
展开全部
、因为参数是通过URL参数提交的,所以在%TOMCAT_HOME%/congf/server.xml中的标签,加入了URIEncoding="UTF-8"属性。
2、修改web.xml的编码过滤进行强制转码,如下:
01 <!-- 编码转换 -->
02 <filter>
03 <filter-name>Set Character Encoding</filter-name>
04 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
05 <init-param>
06 <param-name>encoding</param-name>
07 <param-value>UTF-8</param-value>
08 </init-param>
09 <init-param>
10 <param-name>forceEncoding</param-name>
11 <param-value>true</param-value><!-- 强制进行转码 -->
12 </init-param>
13 </filter>
14
15 <filter-mapping>
16 <filter-name>Set Character Encoding</filter-name>
17 <url-pattern>/*</url-pattern>
18 </filter-mapping>
3、中文参数在传之前要java.net.URLEncoder.encode进行编码
4、接收中文参数的时候要java.net.URLDecoder.decode进行解码,jsp中el表达式直接用{param.参数名}即可
2、修改web.xml的编码过滤进行强制转码,如下:
01 <!-- 编码转换 -->
02 <filter>
03 <filter-name>Set Character Encoding</filter-name>
04 <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
05 <init-param>
06 <param-name>encoding</param-name>
07 <param-value>UTF-8</param-value>
08 </init-param>
09 <init-param>
10 <param-name>forceEncoding</param-name>
11 <param-value>true</param-value><!-- 强制进行转码 -->
12 </init-param>
13 </filter>
14
15 <filter-mapping>
16 <filter-name>Set Character Encoding</filter-name>
17 <url-pattern>/*</url-pattern>
18 </filter-mapping>
3、中文参数在传之前要java.net.URLEncoder.encode进行编码
4、接收中文参数的时候要java.net.URLDecoder.decode进行解码,jsp中el表达式直接用{param.参数名}即可
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询