CharacterEncodingFilter does not translate unicode text in Spring MVC 3.0

I set CharacterEncodingFilter as the first filter 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> <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> 

and in my JSP:

 <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false" %> 

and this:

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 

But, for example, Tรก is transferred from the JSP form back to the controller, and then back to JSP again: T%E

I am doing Google search hours, but cannot find the answer to this problem. Any help would be appreciated.

+4
source share
2 answers

If you are on Tomcat, you may not have installed URIEncoding in your server.xml . If you do not install it in UTF-8, this will not work. Definitely keep a CharacterEncodingFilter . However, a concise checklist follows. It will definitely help you do this job.

+3
source

If the CharacterEncodingFilter or the filter you implement is at the top of web.xml , make sure that the <filter-mapping> elements for the CharacterEncodingFilter in xml are displayed before the other <filter-mapping> elements for the other filters.

I thought about this for a long time. May be helpful to someone.

+1
source

Source: https://habr.com/ru/post/1332442/


All Articles