<%@ page import="java.net.*" pageEncoding="gb2312" %><%
int num;
try {
num = Integer.valueOf(request.getParameter("num"));
} catch (NumberFormatException e) {
num = 0;
}
%><!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>简体中文网页</title>
</head>
<body>
<p>Tomcat8中server.xml的<Connector>标签下必须加上URIEncoding="ISO-8859-1", 否则将无法解析GB2312字符串!</p>
<p><%
String str = request.getParameter("value");
str = new String(str.getBytes("ISO-8859-1"), "gb2312");
out.print(str);
%></p>
<form id="form1" name="form1" method="get">
<input name="value" type="text" id="value" value="<%= str %>">
<input type="submit" value="确 定">
<input name="num" type="hidden" id="num" value="<%= num + 1 %>">
</form>
<p><%
str = request.getQueryString();
str = URLDecoder.decode(str, "gb2312");
out.print(str);
%></p>
</body>
</html>