thymeleaf模板html中文乱码问题


描述:使用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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM