public String getUnicode(String str) throws Exception{
if(!str.equals("")){
byte[] inputBytes = str.getBytes("8859_1");
str=new String(inputBytes,"GB2312");}
else
str="";
return str;
}//end把这个方法写进你的BEAN,再这样调用:
String sql="INSERT INTO `event` ( `id` , `userid` , `when` , `detail` , `comment` , `state` ) VALUES ('', '"+uid+"',NOW(),'"+detail+"', '"+comment+"','"+state+"')";
sql=getUnicode(sql);
sqlbean.execNoResult(sql);
if(!str.equals("")){
byte[] inputBytes = str.getBytes("8859_1");
str=new String(inputBytes,"GB2312");}
else
str="";
return str;
}//end把这个方法写进你的BEAN,再这样调用:
String sql="INSERT INTO `event` ( `id` , `userid` , `when` , `detail` , `comment` , `state` ) VALUES ('', '"+uid+"',NOW(),'"+detail+"', '"+comment+"','"+state+"')";
sql=getUnicode(sql);
sqlbean.execNoResult(sql);
解决方案 »
- 求助解决这个问题:java.lang.NoClassDefFoundError
- the method setDate(int ,Date) in the type PreparedStatement is not applicable for the arguments (in
- 一个困扰很久的web问题,拜托各位了
- 高手帮忙解决个问题
- 请问用jsp如何实现发送邮件时“增加附件”和“删除附件”这样的功能???
- 求救!sybase数据库在jsp页面下中文乱码问题!
- 这是个什么错误?????????????
- 大学生就业咨询系统数据库课程设计
- JSP响应时间设哪个参数?
- 关于弹出窗口的问题,帮忙给分了
- 问个很菜的问题,mysql怎么用的?哪有介绍么?
- 大家在市面上买过D版的WebLogic吗?
return null ;
} String out = str.trim(); if( out.equalsIgnoreCase("")){
return out ;
} try{
out = new String( out.getBytes("ISO8859_1") );
}catch ( java.io.UnsupportedEncodingException e ){
e.printStackTrace();
} return( out );
}
<%@page contentType="text/html;charset=GBK"%>
<%request.setCharacterEncoding("GBK");%>
就没问题了,不用转
<%@page contentType="text/html;charset=GBK"%>
则可以正常显示,有也是??
jdbc:mysql://192.168.0.2:3306/database?useUnicode=true&characterEncoding=GBK这样还不行我去自杀
当我用上面哪个方法转换一下后就可以了这个好像与tomcat没有什么关系呢
些个测试的页面。
<html>
<%@ page language="java" %>
<%@ page contentType="text/html;charset=gb2312" %>
public static String parseToChinese(String str) { if( str == null ){
return null ;
} String out = str.trim(); if( out.equalsIgnoreCase("")){
return out ;
} try{
out = new String( out.getBytes("ISO8859_1") );
}catch ( java.io.UnsupportedEncodingException e ){
e.printStackTrace();
} return( out );
}
</head>
<body>
<%
String strTest = "这是中文" ;
strTest = parseToChinese( strTest ) ;
out.println(strTest) ;
%>
</body>
</html>
http://218.193.178.125:8083/examples/jsp/project/login.htm
用hzqq密123456
源代码在
ftp://jsp:[email protected]:2121/
好人做到底吧,我第一次编jsp就遇到这种问题,哎