public String strIntoDb(String string)
{
String str = null;
try{
str = new String(string.getBytes("gb2312"),"ISO8859-1");
}catch(java.io.UnsupportedEncodingException ue) {
}
return str;
}
{
String str = null;
try{
str = new String(string.getBytes("gb2312"),"ISO8859-1");
}catch(java.io.UnsupportedEncodingException ue) {
}
return str;
}
解决方案 »
- 非action在哪配置services呢?
- 急!!!有关Access数据库的请教
- 日期转换出错
- 又找不到Action了(Struts + Ext2),我x,非常奇怪的问题
- 求帮助!!整个JSP页面变成乱码,用记事本打开也是乱码!!!
- 这个矛盾怎么解决
- 找工作,急需java,jsp项目,急急急急急急急!!!!!!!
- 读取properties文件 取出的汉为ê±?? 有什么办法 解决?
- 急!!请教:JAVA(JSP)能否访问VB等开发的DLL组件
- druid连接mysql报错
- 加载图象
- 请问在制作聊天室(b/s)时如果访问量大的话如同时在线(100-150人),应该采取什么方法或技术手段,普通的方式会不会有问题
-->
String str = new String(string.getBytes("ISO8859_1"),"gb2312");
再问一下,为什么非得抛出这异常?
两个参数的位置我搞混了,能解释一下吗?
所以getBytes,和new String(byte[],enc)都声明
抛出了UnsupportedEncodingException ,所以你只能catch它
new String(change.getBytes("iso-8859-1"),"gb2312")为从数据库中读去;
new String(change.getBytes("gb2312"),"iso-8859-1")为写入数据库。
我的数据库为ORACLE,其他数据库是否要进行该操作未进行测试。