如果数据库能正常显示的话,通常不需要任何转换就可以打印出来
当然也可能是jdbc存在问题,如果是这样建议更换jdbc驱动
还可能是web服务器和操作系统的问题,那我就不是很清楚了。
当然也可能是jdbc存在问题,如果是这样建议更换jdbc驱动
还可能是web服务器和操作系统的问题,那我就不是很清楚了。
解决方案 »
- 本人亲自制作的springMVC教程视频(5),持续更新中
- B/S模式的 网页JMF语音聊天
- js中这样写对吗?
- 问一个容易,但是对我来说很重要的问题!
- 如何编写 在网页又击一个图片能在客户端自动打开powerpoint,并插入到powerpoint编辑
- 我写的分页程序为什么只有第一页,第二页第三页都无法显示呢,那位高手帮我看看谢谢!
- 一个很菜鸟的问题,关于用submit传值,在线等
- TOMCAT部署项目问题
- 急求servlet数据分页显示代码!!
- 如何把界面上显示的从数据库中找出的一条记录转入到另一个.jsp中?
- 同胞们,我的jsp的配置有问题还是我的步骤有问题?
- 高分求教,关于在JSP页面对数据进行排序的问题--谢谢
package com.yangjun.struts.code;public class CharCode
{
public static String UnicodeToChinese(String s)
{
try
{
if(s==null || s.equals(""))
return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(Exception e)
{
return s;
}
}
public static String ChineseToUnicode(String s)
{
try
{
if(s==null || s.equals(""))
return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
return newstring;
}
catch(Exception e)
{
return s;
}
}
}
在jsp页面中用useBean实现
如:<jsp:useBean id="code" class="com.yangjun.struts.code.CharCode"/>
<%=code.UnicodeToChinese(rs.getString(2))%>
等加到jsp页的顶部。
ok
^_^
{
try
{
if (strVal == null)
{
return "";
}
else
{
strVal = strVal.trim();
strVal = new String(strVal.getBytes("ISO8859_1"), "GBK");
return strVal;
}
}
catch (Exception exp)
{
return "";
}
}
/**
* 将数据从数据库中取出后转换,将字符串由“GBK”转换为“ISO8859_1”
*
* @param strVal 要转换的字符串
* @return 从“GBK”到“ISO8859_1”得到的字符串
*/
public static final String toISO(String strVal)
{
try
{
if (strVal == null)
{
return "";
}
else
{
strVal = new String(strVal.getBytes("GBK"), "ISO8859_1");
return strVal;
}
}
catch (Exception exp)
{
return "";
}
}<%@ page contentType="text/html;charset=ISO8859_1"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
或者
<%@ page contentType="text/html;charset=gb2312"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
最有效了
如果按你那么说的话,你数据库里应该就是乱码了
说明你的oracl目前使用的编码支持中文。
2,jsp页面显示中文时出现乱码。
因为java使用的是unicode编码,你要变换后放
到jsp页面上。
把上面语句加到你JSP页面的第一行就可以了。
其中Charset的第一个字符大写,试试看。祝成功!呵呵
<%@ page contentType="text/html;Charset=gb2312" %>
<%@ page contentType="text/html;Charset=GBK" %>
都试过了,不行。
有没有其他方法??
给思路就给分了!!
在你要接受变量的前面加上上面那一句,还要记得在jsp页面最上面加上一句:
<%@ page contentType="text/html;Charset=GBK" %>