post及get请求中文乱码解决方案
来源:互联网 发布:iphone8 usb共享网络 编辑:程序博客网 时间:2024/05/22 14:54
转载自:http://www.cnblogs.com/liukemng/p/4178882.html
之前项目中的web.xml中的编码设置:
<filter> <filter-name>CharacterEncoding</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>CharacterEncoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
但这个设置是针对POST请求的,tomacat对GET和POST请求处理方式是不同的,要处理针对GET请求的编码问题,则需要改tomcat的server.xml配置文件,如下:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
改为:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true"/>
最关键的点在这里:如果你是更改的tomcat安装目录的server.xml配置文件,那么在用eclipse运行项目时会发现配置没起作用,其实是因为eclipse在运行项目时是用的eclipse中配置的tomcat,那么问题就好解决了,打开eclipse中的tomcat配置文件,改为如下即可:
0 0
- post及get请求中文乱码解决方案
- post和get请求中文乱码解决方案
- post和get请求中文参数出现乱码现象解决方案
- NodeMCU教程 http.get请求及上传中文乱码解决方案
- get/post请求:中文乱码问题
- get/post请求中文乱码问题
- get post 中文请求乱码解决方式
- post与get请求中文乱码问题
- SpringMVC-Post/Get请求中文乱码问题
- get,post请求中文乱码问题
- SpringMVC POST/GET 中文乱码 解决方案
- 针对请求GET和POST请求,出现中文乱码
- 解决servlet中文乱码问题及get、post请求方式的讲解
- get,post中文乱码
- get中文乱码/post
- Get,Post请求中文乱码问题有效解决方法
- Get,Post请求中文乱码问题有效解决方法
- 关于Get,Post请求中文乱码问题有效解决方法
- MySQL 复制滞后怎么办?其实方法很简单
- RadioGroup+RadioButton
- 海量数据存储面试题(一)
- 好吧,被博客园拒绝了
- Android网络加载图片并滚动显示
- post及get请求中文乱码解决方案
- c语言 static
- PAT 1005. 继续(3n+1)猜想
- opencv读图片
- MVP的使用
- #!/usr/bin/env python与#!/usr/bin/python的区别
- CentOS6.6配置IP网络
- ====== 4.2不一样======WebView注入Java对象注意事项
- Sql Server(错误:7302)解决