描述:使用thymeleaf生成的html页面中文显示乱码。检查过项目的设置,都已经改成UTF-8。但是查看html相关请求的响应头中,content_type仍然是ISO-8859-1.
解决方法:查资料发现,是thymeleaf框架的问题,需要在配置文件设置html的编码。问题解决。
<bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
<!-- NOTE 'order' and 'viewNames' are optional -->
<property name="order" value="1" />
<property name="characterEncoding" value="UTF-8" />
<property name="viewNames" value="*.html,*.xhtml" />
</bean>
相关资料:https://www.cnblogs.com/peak-c/archive/2015/10/18/4890150.html