第一种方法:
8.jps
<%@page contentType="text/html;charset=gb2312"%>
<html>
<body>
<form action="9.jsp">
<input type="text" name="d1" >
<input type="submit" value="asd">
</form>
</body>
</html>
9.jsp
<%@page contentType="text/html;charset=gb2312"%>
<%
String name;
name=new String(request.getParameter("d1").getBytes("ISO8859-1"),"GBK");
%>
<%=name%>
用到name=new String(request.getParameter("d1").getBytes("ISO8859-1"),"GBK");这个解决中文传送的问题。
第二种方法:
可以在本程序内加入以一下java代码函数,再调用就可以了;
<%!
public String getStr(String str1)
{
try
{
String temp_p=str1;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}
%>
这里要用try ...catch捉异常