tomcat小知识-请求乱码解决方案
来源:互联网 发布:淘宝卖家版电脑版 编辑:程序博客网 时间:2024/05/20 06:51
与页面交互过程中的乱码问题
1.post请求方式乱码解决方案
在web项目中的web.xml文件中配置过滤器,CharacterEncodingFilter
相应jar不能少
在web项目中的web.xml文件中配置项如下
<filter> <filter-name>CharacterEncodingFilter</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> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
2. get请求的乱码解决方案
2.1 在tomcat服务器中,server.xml文件中找到图示中的代码片段,并添加如下代码**
URIEncoding="UTF-8"
最终效果图,保存退出即可
<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
2.2 单个参数的get请求乱码解决方案:
String username = new String(request.getParamter("userName").getBytes("ISO8859-1"),"utf-8");
此代码结束后: username为utf-8
阅读全文
0 0
- tomcat小知识-请求乱码解决方案
- tomcat乱码解决方案与uri,url,urn的知识普及
- tomcat服务器,url get请求中文乱码解决方案
- tomcat乱码解决方案 tomcat 乱码
- Tomcat请求url乱码
- tomcat请求乱码
- tomcat请求乱码问题
- tomcat 请求中文乱码
- tomcat乱码解决方案
- Tomcat乱码解决方案
- tomcat中文乱码解决方案
- tomcat小知识
- tomcat小知识
- tomcat小知识-虚拟目录
- Ajax请求中文乱码解决方案
- HttpURLConnection请求出现乱码解决方案
- Tomcat: 在tomcat5下的get请求会出现乱码的解决方案?
- SpringMVC JQuery Ajax Get Post请求在Tomcat中乱码解决方案
- (STM32 A串口2)接收(STM32 B数据printf2),同时STM32 A使用串口1printf给电脑
- 详解四种基本布局
- Eclipse右键Run as Java application 错误: 找不到或无法加载主类 问题解决方案
- 2017 Multi-University Training Contest
- Android 人脸识别————关于虹软人脸识别SDK引擎使用总结
- tomcat小知识-请求乱码解决方案
- 嵌入式系统概论-1.1
- 剑指offer--机器人运动范围
- 使用BotDetect Captcha在SpringMCV项目中生成验证码图片
- 蓝桥杯练习题 BASIC-1 闰年判断
- css透明度的浏览器兼容以及div的隐藏和显示
- 【求一个数n的前几位】(pow函数)
- 文章标题
- Python数据类型 之 list