I can tell you what JΓΌrgen Holler says at https://jira.springsource.org/browse/SPR-3328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel ,
Add the following filter to web.xml (Servlet 2.4+) to set the encoding:
<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>
EDIT:
CharacterEncodingFilter : Current browsers usually do not set the character encoding, even if they are specified on a page or HTML form. The above filter can either apply its encoding if the request has not yet specified an encoding, or enforces this filter encoding in any case ("forceEncoding" = "true"). If we strictly want to encode characters, we set it forcibly.
- why was it possible to set the response encoding when the request encoding was forcibly set for this encoding?
- Why can't I set the default response encoding if nothing is specified in the acceptance header fields? Or if there was no encoding in the request?
I think Boris's
link in the commentary will answer these questions.
source share