Reputation: 61
I am using Spring mvc 3.2 and need to filter non-ascii characters from the input.
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>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Using Tomcat, but it is not filtering the Non-Ascii characters. Do we need to write a filter to do the above?
Upvotes: 0
Views: 386
Reputation: 870
CharacterEncodingFilter sets up character encoding on request and responce, it not filters any input or output, it's filter because it implements http://docs.oracle.com/javaee/5/api/javax/servlet/Filter.html interface.
Upvotes: 1