主题:JSP页面传值出现乱码问题?
我用HTML页面向一个JSP页面传值的时候,汉字传到JSP页面接收的全变成了乱码,我用了很多字符类型转换的方法都没有用,请高手指点,我用的页面都是UTF-8的.
HTML页面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>TextAbout.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<form action="TextAboutDo.jsp" method="post" enctype="multipart/form-data" name="addText">
<div> 中文输入</div>
<textarea name="context1_ch" rows="8" cols="30"></textarea>
<div>英文输入</div>
<textarea name="context1_en" rows="8" cols="30"></textarea><br>
<input type="submit" name="Upload" value="提交" />
<input type="reset" value="取消">
</form>
</body>
</html>
JSP页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
import="com.jspsmart.upload.*"
import="com.ecommentsgraphic.datamodel.Aoubts"
import="com.ecommentsgraphic.web.AoubtsBean"
import="com.ecommentsgraphic.dal.index.Impl.IndexLoadDalImpl"
import="java.util.List"
import="com.ecommentsgraphic.dal.index.Impl.IndexDalImpl"
import="com.test.Str"
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'TextAboutDo.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.upload();
IndexLoadDalImpl indexLoadDal = new IndexLoadDalImpl();
List list =(List) indexLoadDal.LoadIndexAoubts("from Aoubts");
Aoubts aoub=(Aoubts) list.get(0);
String context1 = su.getRequest().getParameter("context1_ch");
String context2 = su.getRequest().getParameter("context1_en");
out.println(context1);
out.println(context2);
%>
<center><br><br><br>
</center>
</body>
</html>
HTML页面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>TextAbout.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<form action="TextAboutDo.jsp" method="post" enctype="multipart/form-data" name="addText">
<div> 中文输入</div>
<textarea name="context1_ch" rows="8" cols="30"></textarea>
<div>英文输入</div>
<textarea name="context1_en" rows="8" cols="30"></textarea><br>
<input type="submit" name="Upload" value="提交" />
<input type="reset" value="取消">
</form>
</body>
</html>
JSP页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
import="com.jspsmart.upload.*"
import="com.ecommentsgraphic.datamodel.Aoubts"
import="com.ecommentsgraphic.web.AoubtsBean"
import="com.ecommentsgraphic.dal.index.Impl.IndexLoadDalImpl"
import="java.util.List"
import="com.ecommentsgraphic.dal.index.Impl.IndexDalImpl"
import="com.test.Str"
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'TextAboutDo.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.upload();
IndexLoadDalImpl indexLoadDal = new IndexLoadDalImpl();
List list =(List) indexLoadDal.LoadIndexAoubts("from Aoubts");
Aoubts aoub=(Aoubts) list.get(0);
String context1 = su.getRequest().getParameter("context1_ch");
String context2 = su.getRequest().getParameter("context1_en");
out.println(context1);
out.println(context2);
%>
<center><br><br><br>
</center>
</body>
</html>