Home  >  Article  >  Web Front-end  >  jsp关于过滤器顺序的乱码问题_html/css_WEB-ITnose

jsp关于过滤器顺序的乱码问题_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:31:33887browse

写一个小网站,注册jsp提交给service的servlet,中间有两个过滤器characterfilter和loginfilter,在charactefilter输出中文字段username。当web.xml中,characterfilter配置在loginfilter之后的时候输出为???乱码,characterfilter配置在loginfilter之前就没问题,这是什么原因,过滤器执行顺序应该不影响过滤效果吧。不管characterfilter配置到什么顺序应该都会成功设置编码的呀????


回复讨论(解决方案)

过滤器顺序并不影响编码。。。除非楼主在过程中进行了多次转码。。。
最好还是各处统一编码格式,避免乱码BUG。。。

过滤器顺序并不影响编码。。。除非楼主在过程中进行了多次转码。。。
最好还是各处统一编码格式,避免乱码BUG。。。


统一编码的话不就是jsp page-encoding "utf-8"  filter中setCharacterEncoding(“utf-8”)就行了么

response.setCharacterEncoding(“utf-8”)是没问题,但request.setCharacterEncoding(“utf-8”)就不是你想像的哪样了。

如果是get:/xxx?word=中文汉字,当然tomcat用的是默认:iso-8859-1

就会乱码

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn