天天看點

IDEA tomcat中文亂碼

IDEA原先是頁面輸出中文亂碼,後來設定完成後,頁面解決中文亂碼,但是控制台中文亂碼。

在經過如

resp.setContentType("text/html;charSet=utf-8");
resp.setHeader("Content-type", "text/html;charset=UTF-8");
           

以上解決頁面中文亂碼後,tomcat控制台出現中文亂碼,解決方案如下:

1)在tomcat配置的 VM options 中添加 : -Dfile.encoding=UTF-8

IDEA tomcat中文亂碼

2)File-Setting-Editor-File Encodings

IDEA tomcat中文亂碼

經過以上步驟,重新開機IDEA,嘗試運作,如果還是亂碼,繼續以下方法。

3)Help-Edit Custom VM Options

IDEA tomcat中文亂碼

在出現的 idea64.exe.vmoptions ,加入以下代碼:-Dfile.encoding=UTF-8

IDEA tomcat中文亂碼

4)IDEA安裝目錄/bin目錄下:idea.exe.vmoptions、idea64.exe.vmoptions

在以上兩個檔案的最底下,加入:-Dfile.encoding=UTF-8

重新開機IDEA,解決。