【實用小技巧】freemarker模板中文亂碼問題解決


freemarker簡單模板如下:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title>中文</title>
    </head>
    <body>
        <h1>${name}</h1>
        <h2>中文測試</h2>
    </body>
</html>

方案如下:

  • 設置模板文件本身的屬性:右鍵文件,選擇properties,看text file encoding 選擇UTF-8編碼。
  • 在頭部加標簽:<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  • request、response 設置編碼格式為UTF-8。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM