Spring-MVC映射和请求参数乱码

一、映射

1、标准URL映射
2、Ant风格的URL映射*
3、占位符映射 @requestMapping (show/{userid}/{name} ) 方法中(@pathVariable( userid) String id) http://localhost/hello2/833/yanqi.do
4、限制请求方法映射 @requestMapping ( value=“ show2” , method=requestMehtod.POST)
5、限制参数映射 @requestMapping( value=”show3” , params=”abc”) 方法中(@requestParam(“abc”) String abcid)

这五种映射都是书写在请求方法上

二、请求参数乱码问题

Get乱码问题
1,手动解码编码
// username jsp传过来的参数
String name = newString(username.getBytes(“ISO8859-1”), “UTF-8”);
2,配置tomcat服务器解决乱码
service.xml :
<ConnectorURIEncoding=“UTF-8” connectionTimeout="20000"port=“8080” protocol=“HTTP/1.1” redirectPort=“8443”/>

Post乱码问题
spring提供编码过滤器
web.xml:
注意:要配置在拦截器前面
Spring-MVC映射和请求参数乱码
拦截所有
Spring-MVC映射和请求参数乱码

相关文章: