Incorrect string value: '\xE9\x98\xBF\xE6\x96\xAF...' for column 'name' at row 1 form表单提交乱码

2017-03-05 19:35:15,017 DEBUG [com.audio.global.GlobalDisparter] - DispatcherServlet with name 'spring' processing POST request for [/AudioSystem/hui/audioInfoList.ftl]
2017-03-05 19:35:15,018 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] - Matching patterns for request [/hui/audioInfoList.ftl] are [/hui/{pageName}.ftl]
2017-03-05 19:35:15,019 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] - URI Template variables for request [/hui/audioInfoList.ftl] are {pageName=audioInfoList}
2017-03-05 19:35:15,019 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] - Mapping [/hui/audioInfoList.ftl] to HandlerExecutionChain with handler [com.audio.controller.PageController@5a468ebd] and 2 interceptors
2017-03-05 19:35:15,021 DEBUG [org.springframework.web.bind.annotation.support.HandlerMethodInvoker] - Invoking model attribute method: public void com.audio.controller.BaseController.initHttp(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.Model,com.audio.beans.AudioInfo,com.audio.entity.Page)
2017-03-05 19:35:15,022 DEBUG [org.springframework.web.bind.annotation.support.HandlerMethodInvoker] - Invoking request handler method: public java.lang.String com.audio.controller.PageController.login(java.lang.String)
2017-03-05 19:35:15,022 DEBUG [com.audio.controller.PageController] - invode:audioInfoList
2017-03-05 19:35:15,022 DEBUG [org.mybatis.spring.SqlSessionUtils] - Creating a new SqlSession
2017-03-05 19:35:15,022 DEBUG [org.mybatis.spring.SqlSessionUtils] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5c8efd55] was not registered for synchronization because synchronization is not active
2017-03-05 19:35:15,023 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Fetching JDBC Connection from DataSource
2017-03-05 19:35:15,024 DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] - JDBC Connection [jdbc:mysql://localhost:3306/audio?Unicode=true&characterEncoding=UTF-8, UserName=root@localhost, MySQL-AB JDBC Driver] will not be managed by Spring
2017-03-05 19:35:15,024 DEBUG [com.audio.dao.AudioInfoMapper.insertSelective] - ==>  Preparing: insert into t_audio_info ( id, name, create_time, del_flag, price, description ) values ( ?, ?, ?, ?, ?, ? ) 
2017-03-05 19:35:15,024 DEBUG [com.audio.dao.AudioInfoMapper.insertSelective] - ==> Parameters: a0796b8b95dc40b9b89f31f2ad73e62e(String), 阿斯顿(String), 2017-03-05 19:35:15.022(Timestamp), false(Boolean), 1.0(Double), java.io.StringReader@3902655(StringReader)
2017-03-05 19:35:15,025 DEBUG [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator] - Unable to translate SQLException with Error code '1366', will now try the fallback translator
2017-03-05 19:35:15,025 DEBUG [org.springframework.jdbc.support.SQLStateSQLExceptionTranslator] - Extracted SQL state class 'HY' from value 'HY000'
2017-03-05 19:35:15,025 DEBUG [org.mybatis.spring.SqlSessionUtils] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5c8efd55]
2017-03-05 19:35:15,025 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Returning JDBC Connection to DataSource
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.audio.controller.PageController.invoke(PageController.java:94)
at com.audio.controller.PageController.login(PageController.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at com.audio.global.GlobalDisparter.doService(GlobalDisparter.java:16)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.jdbc.UncategorizedSQLException: 
### Error updating database.  Cause: java.sql.SQLException: Incorrect string value: '\xE9\x98\xBF\xE6\x96\xAF...' for column 'name' at row 1
### The error may involve com.audio.dao.AudioInfoMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: insert into t_audio_info      ( id,                       name,                              create_time,                       del_flag,                       price,                       description )       values ( ?,                       ?,                              ?,                       ?,                       ?,                       ? )
### Cause: java.sql.SQLException: Incorrect string value: '\xE9\x98\xBF\xE6\x96\xAF...' for column 'name' at row 1
; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1366]; Incorrect string value: '\xE9\x98\xBF\xE6\x96\xAF...' for column 'name' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xE9\x98\xBF\xE6\x96\xAF...' for column 'name' at row 1
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)
at com.sun.proxy.$Proxy15.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:236)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy17.insertSelective(Unknown Source)
at com.audio.controller.PageController.audioInfoList(PageController.java:70)
... 46 more
Caused by: java.sql.SQLException: Incorrect string value: '\xE9\x98\xBF\xE6\x96\xAF...' for column 'name' at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:882)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:62)
at com.sun.proxy.$Proxy25.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at com.sun.proxy.$Proxy23.update(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
... 52 more
2017-03-05 19:35:15,028 DEBUG [com.audio.global.GlobalDisparter] - Rendering view [org.springframework.web.servlet.view.freemarker.FreeMarkerView: name 'audioInfoList'; URL [audioInfoList.html]] in DispatcherServlet with name 'spring'
2017-03-05 19:35:15,028 DEBUG [org.springframework.web.servlet.view.freemarker.FreeMarkerView] - Added model object 'audioInfo' of type [com.audio.beans.AudioInfo] to request in view with name 'audioInfoList'
2017-03-05 19:35:15,028 DEBUG [org.springframework.web.servlet.view.freemarker.FreeMarkerView] - Added model object 'org.springframework.validation.BindingResult.audioInfo' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'audioInfoList'
2017-03-05 19:35:15,028 DEBUG [org.springframework.web.servlet.view.freemarker.FreeMarkerView] - Added model object 'page' of type [com.audio.entity.Page] to request in view with name 'audioInfoList'
2017-03-05 19:35:15,028 DEBUG [org.springframework.web.servlet.view.freemarker.FreeMarkerView] - Added model object 'org.springframework.validation.BindingResult.page' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'audioInfoList'
2017-03-05 19:35:15,028 DEBUG [org.springframework.web.servlet.view.freemarker.FreeMarkerView] - Removed model object 'void' from request in view with name 'audioInfoList'
2017-03-05 19:35:15,028 DEBUG [org.springframework.web.servlet.view.freemarker.FreeMarkerView] - Added model object 'springMacroRequestContext' of type [org.springframework.web.servlet.support.RequestContext] to request in view with name 'audioInfoList'
2017-03-05 19:35:15,028 DEBUG [org.springframework.web.servlet.view.freemarker.FreeMarkerView] - Rendering FreeMarker template [audioInfoList.html] in FreeMarkerView 'audioInfoList'
2017-03-05 19:35:15,034 DEBUG [freemarker.cache] - TemplateLoader.findTemplateSource("audioInfoList_zh_CN.html"): Not found
2017-03-05 19:35:15,034 DEBUG [freemarker.cache] - TemplateLoader.findTemplateSource("audioInfoList_zh.html"): Not found
2017-03-05 19:35:15,035 DEBUG [freemarker.cache] - TemplateLoader.findTemplateSource("audioInfoList.html"): Found
2017-03-05 19:35:15,035 DEBUG [freemarker.cache] - "audioInfoList.html"("zh_CN", UTF-8, parsed): using cached since D:\developTools\java_workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\AudioSystem\hui\audioInfoList.html hasn't changed.
2017-03-05 19:35:15,036 DEBUG [freemarker.cache] - TemplateLoader.findTemplateSource("menu_zh_CN.html"): Not found
2017-03-05 19:35:15,036 DEBUG [freemarker.cache] - TemplateLoader.findTemplateSource("menu_zh.html"): Not found
2017-03-05 19:35:15,036 DEBUG [freemarker.cache] - TemplateLoader.findTemplateSource("menu.html"): Found
2017-03-05 19:35:15,037 DEBUG [freemarker.cache] - "menu.html"("zh_CN", UTF-8, parsed): using cached since D:\developTools\java_workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\AudioSystem\hui\menu.html hasn't changed.

2017-03-05 19:35:15,039 DEBUG [com.audio.global.GlobalDisparter] - Successfully completed request



解决方法:

1、查看mysql数据库的表的字符集编码,修改为utf-8

2、在web.xml中增加如下配置
setCharacterEncoding
org.springframework.web.filter.CharacterEncodingFilter

encoding
utf-8


 
        setCharacterEncoding  
        /*  
   

你可能感兴趣的:(java)