ssm网站页面乱码问题解决
1.在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>
<!-- 启动过滤器 -->
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<!-- 过滤所有请求 -->
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.在 springmvc 的配置文件中可以配置,静态资源不过滤:
<mvc:resources location="/css/" mapping="/css/**"/>
<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/scripts/" mapping="/javascript/**"/>
或者放行全部静态资源
<mvc:default-servlet-handler></mvc:default-servlet-handler>
3.设置tomcat编码
-Dfile.encoding=utf-8
4.清除浏览器缓存
posted on 2019-06-28 10:14 COMPLEX-B 阅读(1451) 评论(1) 编辑 收藏 举报