今天在做远程医疗项目中,遇到了个较难的中文乱码问题,先不同浏览器(ie6、ie8)之间出现乱码,后查实是不同的tomcat出现乱码
所以有了以下步骤:
1、页面处理两次js encodeURI
<a href="#" οnclick="location.href=encodeURI(encodeURI('/advice/readyGuidance.jspx?personId=${patientId}&patientName=${patientName}))">
2、tomcat中server.xml加了
<Connector URIEncoding="utf-8"
port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" /><Connector URIEncoding="utf-8"
port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
3、action中解码
//patientName = new String(patientName.getBytes("ISO-8859-1"),"utf-8"); //这个是转码
patientName=java.net.URLDecoder.decode(patientName,"UTF-8"); //这个是解码