现在的位置: 首页 > 综合 > 正文

Eclipse使用技巧:Eclipse开发web项目的文件编码设置

2018年02月17日 ⁄ 综合 ⁄ 共 747字 ⁄ 字号 评论关闭

有几种方式设置编码:
1.Window-Preferences-General-Workspace

2.Window-Preferences-General-Editors-Text Editors-Spelling

3.右击左侧Package Explorer中相应的工程或者文件-Properties-Resource

4.Window-Preferences-General-Content Types

5.Myeclipse Enterprise Workbench-Files and Editors-JSP...


6.配置Tomcat编码,tomcat\conf目录下server.xml添加URIEncoding="utf-8"。如下:

    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" 
			   URIEncoding="utf-8"/>

实验得:优先级由高到低是3-1-2

最高的是在文件中指定编码,比如xml文件中、jsp页面中指定该文件的编码方式。

注意:(1) Window-Preferences-General-Content Types下也有设置编码的选项。此处是从文件类型的角度设置编码,不同后缀名的文件采用各自的编码

(2) ansi (iso-8859-1)到utf-8转换正常,utf-8转ansi则有问题(推荐用notepad++,myeclipse,dreamweaver分别打开,看是否有问题)

(3) java web项目还可以通过配置filter来控制编码。参考:http://blog.csdn.net/lovesummerforever/article/details/9924413

抱歉!评论已关闭.