日期:2014-05-17 浏览次数:20728 次
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.uisf.entity.UisfEmp]; uncategorized SQLException for SQL [insert into alex.uisf_emp (name, emp_no, dept) values (?, ?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xC2\x98\xC3\xA5\xC2\xAE...' for column 'name' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xC2\x98\xC3\xA5\xC2\xAE...' for column 'name' at row 1
Caused by: java.sql.SQLException: Incorrect string value: '\xC2\x98\xC3\xA5\xC2\xAE...' for column 'name' at row 1
安装数据库设置的编码是utf8;
spring配置hiebernate的配置文件中也设置了utf8格式:
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/alex?useUnicode=true&characterEncoding=utf-8">
</property>
<property name="username" value="root">
</property>
<property name="password" value="love0824">
</property>
</bean>;
在struts.xml中也设置了utf8的格式:
<constant name="struts.i18n.encoding" value="utf-8"></constant>
<filter>
<filter-name>Set Character Encoding</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>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws java 中 不能读取Text的内容解决方法