In the web based application, it is necessary to encode the incoming request and outgoing response in UTF-8 in order to have a application compliant with all characters.
It exists a http filter to set the contentType attribute including the content type and the encoding of the content writer (see Servlet specification).
The CharacterEncodingFilter class provided by Spring enables an automatic way of setting the character encoding in HttpServletRequest.

It is necessary to add a filter configuration in the web.xml file of your application. Be careful to position the filter in the first position in the list of different filters!

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>