教育改变生活
标题:
ssm框架:中文乱码问题的几种解决方案
[打印本页]
作者:
却尘
时间:
2021-6-26 00:47
标题:
ssm框架:中文乱码问题的几种解决方案
一:项目的编码格式,utf-8(preference->general->workspace)
二:jsp中的编码格式,统一调(preference->myEclipse->jsp),确保页面中都是jsp
三: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>forceRequestEncoding</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>forceResponseEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
四:数据库中,navicat连接和数据库属性中的编码格式都是utf-8
五:设置tomcat的编码格式
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
欢迎光临 教育改变生活 (http://bbs.goldoar.com/)
Powered by Discuz! X3.2