I have met a problem about the charset of the page.
Here is a characterEncodingFilter in 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> and I set the Content-Type to "text/html; charset=UTF-8" in my template file.
Here is code:
You've made me discover a bug in charset specification, thanks. But first, the workaround for what you need:
With the current 1.0.0-beta1 version, you will need to define a ThymeleafView bean with a "name" attribute equal to the template name and set its "contentType" property to "text/html; charset=UTF-8". For example, for a template named "main":
The problem is that, if you have many templates, you will have to do this for every one of them. The ThymeleafViewResolver class has a "contentType" property which should keep you from doing this and should set that contentType to all its "views"/templates (without the need to declare them as beans), but that is precisely where the bug is, and this doesn't work :-(
About your code: the filter has no influence, it is only used for setting the charset of incoming form data. And the <meta> tag should be there for document validness and documentation purposes, but again will not be honored by the browser when determining the charset used by the page (the really important bit is the HTTP header, which you adequately examined).