Eclipse必须设置编码格式的几个地方

1.工作空间编码格式    Windows——preference——Workspace——other(设置为UTF-8)   这种编码格式对整个工作空间的文件都有效

   Eclipse必须设置编码格式的几个地方

2.window -> Preferences -> general -> Workspac -> Text file encoding ->java source  file(设置为utf-8)

  Eclipse必须设置编码格式的几个地方


3. Window->Preferences->General ->Content Type->Text->JSP 最下面设置为UTF-8


4.设置tomcat的编码

方案:

1、找到tomcat的server.xml配置文件

Eclipse必须设置编码格式的几个地方

2、添加URIEncoding="UTF-8"

[html] view plain copy
  1. <Connector port="8080" protocol="HTTP/1.1"  
  2.                connectionTimeout="20000"  
  3.                redirectPort="8443"  URIEncoding="UTF-8" />  
代码中规定了Tomcat监听HTTP请求的端口号等信息。在这里添加了一个属性:URIEncoding,将该属性值设置为UTF-8,即可让Tomcat(默认ISO-8859-1编码)以UTF-8的编码处理get请求,避免中文乱码问题。