This time to do the project encountered a thorny problem: I use ext time to put the Chinese in the URL inside, submitted to the Java server end with
Request.getparameter ("XM")
Immediately out of garbled. The server I use is tomcat, using
New String (Request.getparameter ("XM"). GetBytes ("Iso-8859-1"), "Utf-8")
It's OK. This is why. The reason is that ext submitted the URL with Utf-8 encoding, but after Tomcat was used to encode the iso-8859-1, so in the Java server to first use the Iso-8859-1 string parsing into a byte, No matter what encoding only the byte stream is the only constant, and credible, and then will parse out the byte stream, and then use the Utf-8 code display.
But the statement waits until it is put on WebSphere and then there is garbled. The reason is that URLs are not iso-8859-1 encoded through WebSphere, which is one of the different points between WebSphere and Tomcat.
so I changed the sentence to
New String (Request.getparameter ("XM"). GetBytes ("GBK"), "Utf-8")
Chinese display, but encountered odd words in the last word is always missing or garbled.
So I also adopted the Ext form, using post submission, or garbled.
finally consulted some people who have experience in this field, are said to utf-8 the project is good, so you can not transfer code, directly with
Request.getparameter ("XM")
It's OK, both on Tomcat and WebSphere. So I began to modify the project:
1, first of all the pages, with Notepad to open
<% request.setcharacterencoding ("Utf-8");%>
<% @ Page ContentType = "Text/html;charset=utf-8"%>
and Save as Utf-8 format
2, all used Js,css, are opened in Notepad and saved as Utf-8 format
3, Java server-side code typically outputs response set to
Response.setcontenttype ("text/html; Charset=utf-8 ");
4, if there is web.xml inside the use of filters, remember to set into Utf-8
5, when debugging the page open HttpWatch (this is a very useful debugging tools, monitoring the data flow of the Web page), to observe where there is not charset= "utf-8", Correct the
Such a change, garbled disappeared, do not have to turn the code, direct access, put where all good.
summarize the experience:
1, if there are Chinese places do not put in the URL, it is best to make a form to submit
2, the project adopts utf-8 unification