swfupload 上传文件名乱码,神哪,救救我吧!
我的JSP页面编码方式是GBK 我试了以下方式:
String filePath="D:\\";//这里填写项目中存放上传文件的物理路径
suFile = su.getFiles().getFile(i);
String strNam = suFile.getFileName().toString();
String strN = URLDecoder.decode(strNam, "ISO-8859-1");
String StrN1 = URLDecoder.decode(strN, "utf-8");
String strN2 = URLDecoder.decode(strN, "GBK");
String strN3 = new String(strN.getBytes(),"GBK");
String strN4 = new String(strNam.getBytes("UTF-8"),"GBk");
String strN5 = new String(strNam.getBytes("GBK"),"ISO-8859-1");
String strN6 = new String(strNam.getBytes("UTF-8"));
StringBuffer sbName = new StringBuffer();
sbName.append(filePath);
sbName.append(strN);
System.out.println(strN);
System.out.println(StrN1);
System.out.println(strN2);
System.out.println(strN3);
System.out.println(strN4);
System.out.println(strN5);
System.out.println(sbName.toString());
System.out.println(strN6.toString());
suFile.saveAs(filePath+suFile.getFileName(),SmartUpload.SAVE_PHYSICAL);//保存文件
得到的结果是:
锛?26鏈燂級20110708鍥轰簳缃戠粶 閲囬泦鍑虹幇鐨勯棶棰?-20110802-wlc.doc
锛?26鏈燂級20110708鍥轰簳缃戠粶 閲囬泦鍑虹幇鐨勯棶棰?-20110802-wlc.doc
锛?26鏈燂級20110708鍥轰簳缃戠粶 閲囬泦鍑虹幇鐨勯棶棰?-20110802-wlc.doc
锛?26鏈燂級20110708鍥轰簳缃戠粶 閲囬泦鍑虹幇鐨勯棶棰?-20110802-wlc.doc
閿涳拷26閺堢噦绱?20110708閸ヨ桨绨崇純鎴犵捕+闁插洭娉﹂崙铏瑰箛閻ㄥ嫰妫舵0锟?-20110802-wlc.doc
???26??????20110708????????????+é??é???????°???é??é??-20110802-wlc.doc
D:\锛?26鏈燂級20110708鍥轰簳缃戠粶 閲囬泦鍑虹幇鐨勯棶棰?-20110802-wlc.doc
閿涳拷26閺堢噦绱?20110708閸ヨ桨绨崇純鎴犵捕+闁插洭娉﹂崙铏瑰箛閻ㄥ嫰妫舵0锟?-20110802-wlc.doc
杂都是乱码啊!!!!
这个怎么办啊!我滴神啊!
好心的大哥大姐,给小弟看看哈!!!!!!
[解决办法]
哥们你设为utf-8试试勒,如果不行就这样转换一下看看
String str="";
String str= new String(str.getBytes("ISO-8859-1"),"utf-8");
[解决办法]
前台编码后台解码