test1.jsp page:
Copy Code code as follows:
<%@ page language= "java" import= "java.util.*" pageencoding= "Utf-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>my JSP ' test1.jsp ' starting page</title>
<body>
<a href= "Test2.jsp?name=<%=java.net.urlencoder.encode (" Wang Yunpeng "," Utf-8 ")%>" >test2.jsp</a>
</body>
test2.jsp page:
Copy Code code as follows:
<%@ page language= "java" import= "java.util.*" pageencoding= "Utf-8"%>
<%
String name = Request.getparameter ("name");//get Tomcat ' s string formatter is iso-8859-1
byte[] names = Java.net.URLEncoder.encode (name, "Iso-8859-1"). GetBytes ();//get inner tomcat ' s byte content
name = new string (names, "Utf-8");//get url ' s String formatter is Utf-8
Name = Java.net.URLDecoder.decode (name, "Utf-8");//decode string to Chinese word
%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>my JSP ' test2.jsp ' starting page</title>
<body>
Name:<%=name%>
</body>