下面是一个转换成中文的方法(在接收提交中文数据的Servlet或jsp中进行转换)
//用于转换成中文
public String toChinese(String str)
{
try
{
if (str==null)
{
return null;
}
else
{
String temp=new String(str.getBytes("ISO-8859-1"),"GBK");
return temp;
}
}
catch(Exception e)
{
return null;
}
}
jsp页面里正确显示中文只要在开头加上:
<%@ page language="java" contentType="text/html;charset=GBK" %>
就可以了.
//用于转换成中文
public String toChinese(String str)
{
try
{
if (str==null)
{
return null;
}
else
{
String temp=new String(str.getBytes("ISO-8859-1"),"GBK");
return temp;
}
}
catch(Exception e)
{
return null;
}
}
jsp页面里正确显示中文只要在开头加上:
<%@ page language="java" contentType="text/html;charset=GBK" %>
就可以了.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货