changing the encode characters for Eclipse

孤者浪人 提交于 2019-12-02 13:52:02

问题


How do I to change the encoding on Eclipse ?

I did all of these configurations:

http://uploads.siteduzero.com/files/388001_389000/388662.png
http://uploads.siteduzero.com/files/388001_389000/388661.png
http://uploads.siteduzero.com/files/388001_389000/388660.png
http://uploads.siteduzero.com/files/388001_389000/388659.png

And

Window > Preferences > General > Workspace > 'Other UTF-8'

But, I still get this on my webpage which I had extracted from my DataBase, knowing that the encoding there is perfect (JSP page) :

http://img15.hostingpics.net/pics/136324Capturer4.jpg

and I wrote this in the top of my JSP page :

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

and this into head tags of my page

<meta charset="utf-8" />

回答1:


If you add the next argument in the eclipse.ini:

-Dfile.encoding=UTF-8

And you create a new workspace or delete the .metadata directory in your current workspace (in that case, you can lost your custom configurations, like formating, cleanup...), all configurations (for Java, XML, console, JSP, HTML...) have, by default, UTF-8 encoding.

In another way, if you are using Glassfish 4 (for Java EE 7), the default encoding charset is defined by the operative system. You can check that if you test with a JSP or Servlet and print:

System.getProperty("file.encoding")



回答2:


Assuming all the layers upto your jsp are sending ht eUTF-8 chars properly. Just try setting this on top of your jsp:

<%@ page contentType="text/html; charset=UTF-8" %>



回答3:


I would guess you need to set the contentType in the response header to text/html and character set to UTF-8.



来源:https://stackoverflow.com/questions/18285435/changing-the-encode-characters-for-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!