jsp连oracle数据库时 中文乱码问题??? new String(xxx.getBytes("ISO8859_1"),"GBK") 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 這不單是oracle的問題.在jsp中很多地方都會遇到亂碼問題.你用這個函數轉換一下就可以了.<%!public String TranStrType(String str) throws Exception{ try{ if(str==null) return null; else { str = new String(str.getBytes("ISO8859-1")); return str; } }catch(Exception e){ return null; } }%>例子<% String Str_Name=TranStrType(request.getParameter("name")); String Str_Card_id=request.getParameter("Card_id");%> To liucm(雪山飞狐) :如果我数据库数据已存在怎么办? liangxuan1979(不贪) : 还是不行;我用下面的方法:System.out.println("打印数据库数据 is:" + TranStrType(rs.getString("name")));‘is:’前是正常的 rs.getString("name")得到的汉字就不正常了 都是“????” 如果你数据库中已经存入乱码,又不想删除,可能只能在显示时用str = new String(str.getBytes("ISO8859-1")); 函数再转换一下 liucm(雪山飞狐) : 我用lingxuan1979的函数转换了一下 还是不行使用前 汉字显示为:鎶曡瘔寤鸿鏌使用后 汉字显示为:??????? jsp开头有这个吗?<%@page contentType="text/html;charset=GBK"%>如没有加上 liucm(雪山飞狐): 我加的是gb2312 GBK也试过 都不行 <%@ page contentType="text/html;charset=iso8859_1" %><%@ page contentType="text/html;charset=GBK" %><%@ page contentType="text/html;charset=gb2312" %><meta http-equiv="Content-Type" content="text/html; charset=gb5">strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK"); strvalue = new String(strvalue.getBytes("ISO8859_1"), "gb2312"); strvalue = new String(strvalue.getBytes("gb2312"), "ISO8859_1"); 大概就这几种办法每种方法分别都试一下! 怎么在jsp网页中分页显示数据库中的数据 怎样在jsf中执行sql语句 使用jsp上传文件时,上传好的文件保存在什么地方??急呀!!!! jquery.jmpopups-0.5.1.js使用问题 各位做过上传的朋友,你们实现后的上传速度是多少 急问:javaBean连接数据库的问题! 数据库操作中的问题。 请问有没有搞struts的阿? 哪位高手赐教java和jsp,等编程规范 一个关于数据库查询的问题(菜鸟) 请大家给小弟提供学JSP的宝贵意见. 做过b/s结构web页面打印的请进!
你用這個函數轉換一下就可以了.
<%!
public String TranStrType(String str) throws Exception
{
try{
if(str==null)
return null;
else
{
str = new String(str.getBytes("ISO8859-1"));
return str;
}
}catch(Exception e){
return null;
}
}%>
例子
<%
String Str_Name=TranStrType(request.getParameter("name"));
String Str_Card_id=request.getParameter("Card_id");
%>
还是不行;
我用下面的方法:
System.out.println("打印数据库数据 is:" + TranStrType(rs.getString("name")));‘is:’前是正常的 rs.getString("name")得到的汉字就不正常了 都是“????”
<%@page contentType="text/html;charset=GBK"%>
如没有加上
<%@ page contentType="text/html;charset=GBK" %>
<%@ page contentType="text/html;charset=gb2312" %>
<meta http-equiv="Content-Type" content="text/html; charset=gb5">
strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
strvalue = new String(strvalue.getBytes("ISO8859_1"), "gb2312");
strvalue = new String(strvalue.getBytes("gb2312"), "ISO8859_1"); 大概就这几种办法每种方法分别都试一下!