how to use org.springframework.web.filter.CharacterEncodingFilter to correct character encoding?
character-encoding, hibernate, spring, tomcat6
Solution
I tried successfully with this in `web.xml` !
<filter>
<filter-name>encodingFilter</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>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Problem
I need some help. I placed the code snippet below in my `web.xml`. ``` <filter> <filter-name>encodingFilter</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> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ``` and in my `server.xml`: ``` <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/> ``` My jsp pages are encoded as `UTF-8` and my mysql table is encoded as `utf8_general_ci`. My problem is that whenever I save a `ñ` it becomes `?`. When I tried to manually save `ñ` in the mysql terminal its saving properly. I suspect the problem lies within my server or my program. Please help.