struts2 get方式传中文乱码
来源:互联网 发布:淘宝怎么定做地毯 编辑:程序博客网 时间:2024/05/22 05:23
解决方法1:
若使用tomcat, 打开server.xml, 找到如下, 加下URIEncoding="UTF-8", 大概在50行左右
这种方法比较简单, 但是依赖于web容器, 不知道化成其他容器后会不会还有类似的设置?
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
解决方法2:
通过指定编码构造一个新的字符串, 但这种方法用于post会出现问题,问题在于getBytes中的字符编码
post默认不是用“ISO-8859-1”的所以以下方法是用在post传值中是不可取的
condition = new String(condition.getBytes("ISO-8859-1"), "utf-8");
解决方法3:(网上的思路是这样的, 但我试了下不行?)
添加filter, 对参数进行处理
public class CharFilter implements Filter{public void destroy() {}public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {request.setCharacterEncoding("utf-8");chain.doFilter(request, response);}public void init(FilterConfig filterConfig) throws ServletException {}}
- struts2 get方式传中文乱码
- <a href> get方式传中文乱码
- Ajax 传中文参数乱码问题(Post和Get方式)
- IE下get方式传中文参数乱码解决方法
- struts2超链接传中文乱码
- html之间通过get方式在地址栏解决传中文乱码问题
- get方式地址栏传中文参数乱码 及 form表单利用jquery.serialize()序列化中文参数乱码 解决总结
- Java web项目中,通过get方式传中文参数时,获得的参数为乱码的解决方案
- jsp重定向中文乱码(get传中文)
- Spring框架下 get方法传中文 乱码
- struts2的s:url标签传中文参数乱码问题
- struts2传中文参数到action乱码解决方法
- URL传中文乱码
- url传中文乱码
- android http传中文乱码
- jsp页面传中文 乱码
- 地址栏中传中文乱码
- js 传中文乱码问题
- Unity3D 将script 'xxx' 绑定到object上提示 Script 'xxx' has not finished compliation yet. ....
- 16. 谨记80-20规则
- 第八周实验报告4
- SQL语句 UNION 和 UNION ALL 使用
- net中异步执行(一)
- struts2 get方式传中文乱码
- 任务切换过程。
- DrawText换行显示的方法
- Linux下USB鼠标驱动完全注释
- lucene笔记
- 在Qt中设置休眠
- TabHost使用(三)
- net Winform socket 套接字聊天室客户端和服务端 源码
- MFC 中的多线程(Work线程)