Spring MVC UTF-8 Encoding Problem SOLVED Risoluzione di un noto problema relativo all'encoding di alcuni caratteri speciali all'interno di applicazioni web.

Pubblicato da lentux-informatica il

  •  
  •  
  •  
  •  
  •  

Now we see how to solve Spring MVC UTF-8 Encoding Problem.

When you try to send special characters like è,à,ù, etc etc, may be you see in your Jsp Post page many characters like '£','Ä’ or ‘Æ’.

UTF-8 is the most common character encoding used in web applications.

It supports all languages currently spoken in the world including Chinese, Korean, and Japanese.




In this article, we demonstrate all configuration needed to ensure UTF-8 in Tomcat.

To solve this problem in 99% of cases you may  move in your web.xml this piece of code at the head of file:

 <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>

So, the first filter in web.xml must be this piece of code and it work!!!


  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Categorie: Tips