Workaround: Before passing the parameters of the Chinese parameter two times encoding, JSP page to get parameters after the Chinese parameter decoding, Chinese parameters will not become garbled!
Reference Example:
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "UTF-8"%>
<%@ page import= "java.net.*"%>
<%
String str0= "";
String str1= "";
if (Request.getparameter ("Param0")!=null) {
Str0=request.getparameter ("Param0");//Direct access to Chinese parameters
}
try{
if (Request.getparameter ("param1")!=null) {
Str1=urldecoder.decode (Request.getparameter ("param1"), "Utf-8");//decoding of Chinese parameters
}
}catch (Exception e) {
E.printstacktrace ();
}
%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script type= "Text/javascript" >
var str= "Hello";
function Test0 () {
window.location= "test.jsp?param0=" +str;//pass Chinese parameters directly
}
function Test1 () {
window.location= "test.jsp?param1=" +encodeuri (encodeURI (str));//double-encode the Chinese parameters before passing
}
</script>
<body>
<input VALUE=<%=STR0%>>
<input type= "button" value= "garbled" onclick= "test0 ()" ><br>
<input VALUE=<%=STR1%>>
<input type= "button" value= "normal" onclick= "test1 ()" >
</body>
Transferred from: http://www.cnblogs.com/nicholas_f/archive/2009/03/27/1423263.html
JavaScript passes URL to JSP page Chinese parameter garbled solution