Test. jsp:
<% @ Page contenttype = "text/html; charset = UTF-8" %>
<HTML>
<Head>
<Title> test </title>
</Head>
<Body>
<H1> test
<A href = "test1.jsp? Username = <% = java.net. urlencoder. encode ("") %> "> Wang Tianji </a>
<Form method = "Post" Action = "test1.jsp" name = "form1">
<Input type = "text" name = "username">
<Input type = "Submit" name = "submit1" value = "click">
</Form>
</Body>
</Html>
Test1.jsp:
");
Byte [] AA = username. getbytes ("ISO-8859-1 ");
String BB = new string (AA, "UTF-8 ");
Out. println ("after:" + BB );
%> <% @ Page contenttype = "text/html; charset = UTF-8" %>
<HTML>
<Head>
<Title>
Test1
</Title>
</Head>
<Body bgcolor = "# ffffff">
<%
String username = "";
Username = request. getparameter ("username ");
Out. println ("before:" + username + "<br> ");
Byte [] AA = username. getbytes ("ISO-8859-1 ");
1. If you want to upload Chinese characters in the address bar, the application is as follows:
String BB = new string (AA );
2. If the form is submitted, the application is as follows:
String BB = new string (AA, "UTF-8 ");
Out. println ("after:" + BB );
%>
</Body>
</Html>
");
Byte [] AA = username. getbytes ("ISO-8859-1 ");
String BB = new string (AA, "UTF-8 ");
Out. println ("after:" + BB );
%> ");
Byte [] AA = username. getbytes ("ISO-8859-1 ");
String BB = new string (AA, "UTF-8 ");
Out. println ("after:" + BB );
%> ");
Byte [] AA = username. getbytes ("ISO-8859-1 ");
String BB = new string (AA, "UTF-8 ");
Out. println ("after:" + BB );
%>