同一文件在 Eclipse 中以不同編碼開啟會產生亂碼。Eclipse 提供四層編碼配置,優先級由低到高:
Window → Preferences → General → Workspace → Text file encoding(預設跟隨作業系統)Properties → Resource → Text file encoding,預設勾選 "Inherited from container"Preferences → General → Content Types → Text → Java Source File → Default encoding,手動輸入編碼後必須點擊 UpdateProperties → Resource → Text file encoding,單檔最高優先級<%@ page contentType="text/html;charset=UTF-8" %> 僅影響瀏覽器渲染,不影響 Eclipse 編輯器解碼團隊統一:Workspace 設 UTF-8、專案鎖定 UTF-8、Content Type 主流類型全設 UTF-8、Git 強制 text=auto eol=lf。