试试
<%@ page contentType="text/html; charset=gb2312" %>
<% request.setCharacterEncoding("GB2312"); %> <%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t,"GB2312");
return temp;
}
catch(Exception e)
{
e.printStackTrace();
}
return "null";
}
%>
<%!String tt;%>
<%
tt=request.getParameter("MC");
//中文转换
//tt=getStr(tt);
tt=java.net.URLDecoder.decode(tt,"8859_1");
out.println(tt);
%>
<%@ page contentType="text/html; charset=gb2312" %>
<% request.setCharacterEncoding("GB2312"); %> <%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t,"GB2312");
return temp;
}
catch(Exception e)
{
e.printStackTrace();
}
return "null";
}
%>
<%!String tt;%>
<%
tt=request.getParameter("MC");
//中文转换
//tt=getStr(tt);
tt=java.net.URLDecoder.decode(tt,"8859_1");
out.println(tt);
%>
{
public static String translateORACLEToJSP(String str)
{
String tempStr="";
try
{
tempStr=new String(str.getBytes("gb2312"),"ISO-8859-1");
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
return tempStr;
}
public static String translateJSPToORACLE(String str)
{
String tempStr="";
try
{
tempStr=new String(str.getBytes("ISO-8859-1"),"gb2312");
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
return tempStr;
}
}
<% request.setCharacterEncoding("GB2312"); %> <%!
public static String translateJSPToORACLE(String str)
{
String tempStr="";
try
{
tempStr=new String(str.getBytes("ISO-8859-1"),"gb2312");
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
return tempStr;
}
%>
<%!String tt;%>
<%
tt=request.getParameter("MC");
//中文转换
tt=getStr(tt);
out.println(tt);
%>
<%@ page contentType="text/html; charset=gb2312" %>
<% request.setCharacterEncoding("GB2312"); %> <%!
public static String getStr(String str)
{
String tempStr="";
try
{
tempStr=new String(str.getBytes("ISO-8859-1"),"gb2312");
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
return tempStr;
}
%>
<%!String tt;%>
<%
if(!"".equals(tt)){
tt=request.getParameter("user");
//中文转换
tt=getStr(tt);
out.println(tt);
}
%>
public static String strToGB2312(String str){
String newStr = null;
try {
newStr = new String(str.getBytes("ISO8859_1"), "GB2312");
}catch (Exception e) {
}
return newStr;
}
<% request.setCharacterEncoding("GB2312"); %> <%!
public String getStr(String str)
{
String tempStr="";
try
{
tempStr=java.net.URLDecoder.decode(str,"8859_1");;
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
return tempStr;
}
%>
<%!String tt;%>
<%
tt=request.getParameter("MC");
//中文转换
tt=getStr(tt);
out.println(tt);
%>
<% request.setCharacterEncoding("GB2312"); %> <%!
public String getStr(String str)
{
String tempStr="";
try
{
tempStr=java.net.URLDecoder.decode(str,"8859_1");;
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
return tempStr;
}
%>
<%!String tt;%>
<%
tt=request.getParameter("MC");
//中文转换
tt=getStr(tt);
out.println(tt);
%>
<% request.setCharacterEncoding("GB2312"); %>
<%
tt=request.getParameter("MC");
//中文转换
//tt=getStr(tt);已经不需要再转码了,你的request不是已经设完了吗?
out.println(tt);
%>
<% request.setCharacterEncoding("GB2312"); %> <%!
public String getStr(String str)
{
String tempStr="";
try
{
tempStr=java.net.URLDecoder.decode(str,"8859_1");;
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
return tempStr;
}
%>
<%!String tt;%>
<%
tt=request.getParameter("MC");
//中文转换
tt=getStr(tt);
out.println(tt);
%>