Problem:
<A class = "a_ope" href = "hitinfoqueryservlet? Query_type = detail & music_singer = Hemingway "> details </a>Pass Chinese parameters through URL through click connection
The Chinese parameter of the URL in the hitinfoqueryservlet squadron is used to convert the character set recommended by most people.
The Code is as follows:New String (Singer. tostring (). Trim (). getbytes ("iso8859-1"), "UTF-8 ")Tomcat default character is iso8859-1
However, after conversion, the Chinese string becomes "Hamming ?" .
Solution:
Change the original connection<A class = "a_ope" href = "hitinfoqueryservlet? Query_type = detail & music_singer = <% = urlencoder. encode ("Hemingway", "UTF-8") %> "> details </a>Then, the servlet code remains unchanged, and you can still convert the character set.
Of course, in this example, the prerequisites are:
Response. setcharacterencoding ("UTF-8 ");
Request. setcharacterencoding ("UTF-8 ");
Response. setcontenttype ("text/html; charset = UTF-8 ");
If you want to change to another character set, replace UTF-8 with the character set you need.