Test1.jsp page:
Copy codeThe Code is as follows:
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" %>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> My JSP 'test1. jsp 'starting page </title>
</Head>
<Body>
<A href = "test2.jsp? Name = <% = java.net. URLEncoder. encode ("Wang yunpeng", "UTF-8") %> "> test2.jsp </a>
</Body>
</Html>
Test2.jsp page:
Copy codeThe Code is 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">
<Html>
<Head>
<Title> My JSP 'test2. jsp 'starting page </title>
</Head>
<Body>
Name: <% = name %>
</Body>
</Html>