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