今天测试了一下关于汉字编码的问题,过程如下:
在main.jsp中的jsp的指令标记中设contentType = "text/html;Charset=UTF-8"
这个没问题,汉字能正常显示.提交后将main.jsp中的action转交给child.jsp页面.在child页面中使用request的getParameter
取出从main.jsp页面中传过来的参数,本例取main.jsp中一个文本输入框的内容.再在child.jsp页面中显示该参数值.
问题就出来了,如果main.jsp文本框传过来的是汉字,则显示的是乱码,child.jsp的指令标记中也设置了contentType = "text/html;Charset=UTF-8",为何getParameter的取值会是乱码呢?  
我又跑去查了耿详义的书,曰:将Charset设置为GB2312,我照做了,不行,还是乱码,外加连原本页面上正常的汉字也变成乱码了.
我就郁闷了,如果getParameter取出的汉字会是乱码,那使用给方法取出参数值再写至数据库中的不全是乱码了吗?
紧急求助,望高手指正!以下是两段程序的源码:
main.jsp<%@ page language="java" contentType="text/html; Charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="child.jsp" name = "form1" method = "post">
<input type = "text" name = "boy">
<input type = submit value = "提交给Charset" name = "btn1">
</form>
</body>
</html>child.jsp<%@ page language="java" contentType="text/html; Charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<p>获取文本框的内容:
<%
String textContent = request.getParameter("boy");
%>
<br>
<%= textContent %>
</body>
</html>