Eclipse JSP: incorrect default text file encoding

前端 未结 4 2098
深忆病人
深忆病人 2021-02-08 15:19

I\'ve got the following problem. I created a new \"Dynamic Web Project\" and imported some existing jsp files into it.

If i right click one of the imported jsp files an

相关标签:
4条回答
  • 2021-02-08 15:58

    It's not a bug, it's a feature

    Eclipse didn't "determine" the correct encoding by scanning the file as like file or iconv commands on your shell.

    Solution: Add following line to your JSP:

    <%@ page pageEncoding="UTF-8" %>
    

    This is a good Idea due to many Web-Container will force to deliver ISO-8859-1 encoded files nevertheless you have set the correct content type in your HTML Header.

    FYI: Mismatching CharacterSets and file encodings will lead

    • to characters like in "Schei� encoding" (Latin1 character in UTF8 (multiByte) context).
    • If you got something like "für" it is indead a broken multibyte character (typically UTF-8) in a singleByte character context (Latin1 / ISO-8859-1 || ISO-8859-15 for Germans)
    0 讨论(0)
  • 2021-02-08 16:01

    In Eclipse, go to Windows -> Preferences -> Web -> JSP Files

    Select UTF-8 encoding from the *Encoding *dropdown box there.

    0 讨论(0)
  • 2021-02-08 16:03

    What are the encoding settings in Window > Preferences General > Workspace, Web > JSP Files and in the Project Properties > Resource? They all have to be correct.

    0 讨论(0)
  • 2021-02-08 16:10

    Windows >Preferences > General > Content Types > Text > JSP > Default Encoding > UTF-8

    0 讨论(0)
提交回复
热议问题