Eclipse JSP: incorrect default text file encoding

前端 未结 4 2100
深忆病人
深忆病人 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)

提交回复
热议问题