| 发表于:2007-09-13 16:05:01 楼主 |
mulitpartrequest mr=new multipartrequest(request,savedir,maxsize, "gbk "); string type=mr=getparameter( "type "); out.println(type); //在jsp里是正常的,因为jsp里有 // <%@page contenttype= "text/html;charset=gb2312 "%> //在servlet 里加上gb2312也可以,但就是写入数据库就是??? ???何解???????????????/ 数据库是mysql 在插入数据库前就得新编码了! string type=new string(mr.getparameter( "type ").getbytes( "utf-8 "), "gb2312 "); 或 string type=new string(mr.getparameter( "type ").getbytes( "gb2312 "), "gb2312 "); 或 string type=new string(mr.getparameter( "type ").getbytes( "iso-8859-1 "), "gb2312 "); 过滤器//request.setcharacterencoding( "gb2312 "); //中文转换 public static string tochinese(string str) { if (str == null) { return null; } try { return new string(str.getbytes( "iso-8859-1 "), "gb2312 "); } catch (unsupportedencodingexception ex) { return " "; } 以上这些,知道的不知道的(我把数据库的编码也改成gb2312/iso-8859-1/utf-8)都用了,我崩溃到死的边缘了 |
|
|
|
|