Reputation: 136
I'm having some problems to add utf-8 to my existing project.
I've seen the solution in this post utf-8 spring
But in my web.xml I have spring security filter, so how can I include another filter in my web.xml ?
web.xml
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I need to include these new lines (to allow utf-8 encoding)
<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>
Upvotes: 0
Views: 178
Reputation: 11787
There is no problem having more than one filter in a web.xml
. I would simply recommend to put the encoding filter at first.
There is an example with multiple filters in the documentation of Oracle.
Upvotes: 1