spring mvc 中文参数乱码
最近做项目,springmvc的url中文参数乱码:
请求url:
http://localhost:8080/supply/supply_list.htm?productName=测试&isHomePage=
在后端:
@RequestMapping(value = SupplyURL.SUPPLY_LIST, method = RequestMethod.GET)
public String toSupplyList (Model model, String productName) { PageBean<Supply> pagination = supplyFacade.querySupplyByPage(searchSupplyVO); model.addAttribute("searchSupplyVO", searchSupplyVO);return "/supply/supply_list";
}
这里productName的值就变成了乱码,
检查我的web的web.xml中已经增加了过滤中文编码的:
<!-- Character Encoding filter -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
但是还是乱码。
仔细检查了,还是中间容器tomcat导致的。修改tomcat的conf/server.xml中的
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" useBodyEncodingForURI="true" URIEncoding="UTF-8" />
加上useBodyEncodingForURI="true" URIEncoding="UTF-8" 。即可。
比如我要下载
http://localhost:8080/template/档案模板.xls
会转义成如下的,此时如果加上 URIEncoding="UTF-8" ,则可以在webapp/template/目录下找到文件。不会再报404了。
http://localhost:8080/template/%E5%AD%A6%E7%94%9F%E6%A1%A3%E6%A1%88%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xls
详细参考本人另一篇博文:
http://www.cnblogs.com/gmq-sh/p/7492126.html
spring mvc 中文参数乱码的更多相关文章
- spring mvc 中文乱码 post与get的方法解决
spring mvc表单提交中文参数乱码问题 今天测试spring mvc ,中文乱码,在web.xml中加上 <filter> <filter-name>encodingF ...
- tomcat解决GET请求中文参数乱码
通常,在使用Spring MVC框架的应用程序中,为了解决中文参数乱码的问题,都会添加如下过滤器配置: <filter> <filter-name>encodingFilter ...
- spring mvc json 返回乱码问题解决(vestion:3.x.x)
本文是转载文章,感觉比较好,如有侵权,请联系本人,我将及时删除. 原文网址:<spring mvc json 返回乱码问题解决(vestion:3.x.x)> 工程中用springmvc返 ...
- Spring MVC接收参数(Map,List,JSON,Date,2个Bean)(记录一次面试惨状)
题目Spring MVC 接收参数 MapListDate2个BeanJSON Spring MVC接收参数 -Map Spring MVC接收参数 -List Spring MVC接收参数 -dat ...
- ajax 中文参数乱码问题不一定是编码格式问题。
代码要修改用户的信息,写了三个ajax,第一个写完测试没有问题,后面俩逻辑一样的就直接复制粘贴了.到第二个ajax测试的时候发现中文会乱码 如下 $.ajax({//中文参数乱码 url: '/edi ...
- js的url中传递中文参数乱码,如何获取url中参数问题
一:Js的Url中传递中文参数乱码问题,重点:encodeURI编码,decodeURI解码: 1.传参页面Javascript代码: <script type=”text/javascript ...
- URL链接中文参数乱码的若干处理方法
JAVA 中URL链接中文参数乱码的若干处理方法,现在整理收录如下: 方法一: (1) JS中,在URL参数中确保用UTF-8编码,用js函数encodeURI()编码,例如 url:"xx ...
- struts2中form提交到action中的中文参数乱码问题解决办法(包括取中文路径)
我的前台页是这样的: <body> <form action="test.action" method="post"> ...
- java url中文参数乱码问题
http://www.blogjava.net/jerry-zhaoj/archive/2009/07/16/286993.html 转 JAVA 中URL链接中文参数乱码的处理方法JAVA 中URL ...
随机推荐
- 关于delphi exit 继承
父类窗体frm 继承下来一个子类 form2 父类按钮代码 procedure Tfrm.Button1Click(Sender: TObject); begin ShowMessage('); Ex ...
- git: 修改commiter 信息
Committer: root root@localhost.localdomain 您的姓名和邮件地址基于登录名和主机名进行了自动设置.请检查它们正确 与否.您可以通过下面的命令对其进行明确地设置以 ...
- 2016福州大学软件工程Beta阶段团队作业成绩汇总
1.评分规则 本次Beta阶段团队作业评分方法如下: 团队得分=[[7次scrum过程评分+(小组互评得分+教师评分)/2]/2],其中过程.小组.教师各30分 说明:由于没有规定提交团队贡献比,因此 ...
- coreseek 安装及使用方法详解
coreseek 安装及使用 一般站点都需要搜索功能,如果是php+mysql站点,建议选择coreseek,如果是java站点建议使用lucene,coreseek 是一款很好的中文全文检索/搜索软 ...
- springboot + mysql 编写
1.springboot+mysql连接因为用的是hibernate框架,所以首先修改model,增加如下内容:
- Java 随机抽奖
package Third; import java.util.Scanner; public class LotteryOdds { public static void main(String[] ...
- Python socket编程之八:阶段性总结
f1.py # -*- coding: utf-8 -*- import sqlalchemy import tushare import pandas import socket import st ...
- centos 7.0 安装nginx 1.117
php官方下载地址 http://cn2.php.net/downloads.php
- Spring Boot整合Dubbo框架demo
Dubbo框架原理见之前的博文:http://www.cnblogs.com/umgsai/p/5836925.html 首先启动zookeeper Server端 Pom配置如下 <?xml ...
- 以冒泡排序为例--malloc/free 重定向stdin stdout
esort.c 代码如下,可关注下mallloc/free,freopen重定向的用法,排序为每轮将最小的数放在最前面: #include<stdio.h> #include<mal ...