页面中添加如下代码:
<%@ page contentType="text/html;charset=gb2312" %>
<%request.setCharacterEncoding("gb2312");%>
可以解决除数据库操作的问题
数据库独处
String newStr = new String(oldStr.getByte("ISO-8859-1"),"gb2312");
<%@ page contentType="text/html;charset=gb2312" %>
<%request.setCharacterEncoding("gb2312");%>
可以解决除数据库操作的问题
数据库独处
String newStr = new String(oldStr.getByte("ISO-8859-1"),"gb2312");
'======================================
不支持此属性啊?
<!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=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
String name = new String((request.getParameter("name")).getBytes("ISO-8859-1","gb2312");
out.println(name);
%>
</body>
</html>
'==================================
能否把这段代码试运行一下,再告诉我?
<!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=gb2312">
<title>no title document</title>
</head><body><%! String ISO2GBK(String input)
{
try{
String output="";
output=new String(input.getBytes("ISO-8859-1"),"GBK");
return output;
}
catch(Exception e){
System.out.println(e.getMessage());
}
return null;
}
%>
</body>
</html>
'========================================
如果以后大家要用的话,只要在你的jsp中加上:
<%@ include file="filepath/Global.jsp" %>输出的时候用此函数就可以了,
<%
out.println(ISO2GBK(request.getParameter("name")));
%>