Blogger Information
Blog 75
fans 0
comment 0
visits 55270
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
小猿圈java之spring编码过滤器
聆听的博客
Original
607 people have browsed it

SP页面和JAVA代码中使用了不同的字符集进行编码的时候就会出现表单提交的数据或者上传/下载中文名称文件出现乱码的问题,针对这个问题,小猿圈老师给出了解决方法,有这个问题的朋友们,过来看一下吧。

web.xml中增加spring编码过滤器:

实例

<!-- spring编码过滤器-->

    <filter> a

        <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>

运行实例 »

点击 "运行实例" 按钮查看在线实例

这样就OK了,在web.xml加上spring的编码过滤器,遇到中文乱码的朋友们可以试试,能帮助你解决心头之患,小猿圈有更多学习的小技巧,需要的可以去看一下,希望能帮到你。

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post