ssm框架插入mysql數據庫中文亂碼問題解決
1. 檢查web.xml
<!-- 編碼過濾器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2. 檢查建表腳本:
CREATE TABLE `t_user_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(40) NOT NULL COMMENT ‘用戶名‘,
`password` varchar(255) NOT NULL COMMENT ‘密碼‘,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘用戶信息表‘;
3. 檢查項目工程及jsp/java/xml文件
4. 檢查jdbc.properties
url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=UTF-8
(詳見:http://blog.csdn.net/lj402159806/article/details/54139131)
ssm框架插入mysql數據庫中文亂碼問題解決