正如标题所示,我只能补充说,如果我在html文件中手动输入ąęó,没关系.
视图解析器:
- <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
- <property name="prefix" value="/WEB-INF/templates/" />
- <property name="suffix" value=".html" />
- <property name="templateMode" value="HTML5" />
- <property name="cacheable" value="false"/>
- <property name="characterEncoding" value="UTF-8"/>
- </bean>
- <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
- <property name="templateResolver" ref="templateResolver" />
- </bean>
- <bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
- <property name="templateEngine" ref="templateEngine" />
- <property name="characterEncoding" value="UTF-8"/>
- <property name="order" value="1"/>
- </bean>
pom.xml中:
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
html输入示例:
- <h2><p th:text="#{homepage.greeting}">Welcome</p></h2>
- <Meta charset="UTF-8"/>
在IntelliJ Idea中,我将项目编码设置为UTF-8,默认编码为UTF-8的属性文件
我真的不知道问题在哪里.当我将locale更改为pl时,这是输出:
对不起,我还没有张贴图片.
任何帮助将不胜感激.
在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>
解决方法
好的,我想出来了这是交易:
我有以下代码:
- <bean id="messageSource"
- class="org.springframework.context.support.ResourceBundleMessageSource">
- <property name="basename" value="messages" />
- </bean>
- <property name="defaultEncoding" value="UTF-8"/>
选项二:
更改为:
- <bean id="messageSource"
- class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
- <property name="basename" value="classpath:messages"/>
- <property name="defaultEncoding" value="UTF-8"/>
- </bean>
如果将其更改为可重新加载,请记住还要将属性值从“消息”更改为“classpath:messages”.由于某种原因,如果我没有更改它,它找不到邮件包.