FileUpload坑的汇聚

*、ServletFileUpload 乱码之FileItem

str = new String((item.getString("iso8859-1")).getBytes("iso8859-1"),"code");  
其中code:你的目标编码

*、ServletFileUpload 乱码之文件对象

ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("code");
其中code:你的目标编码

*、ServletFileUpload 乱码之字符串乱码

可尝试一下方法:
一、str = str2.getBytes("UTF-8");
二、str = new String((str2.getBytes("sourceCode")),"aimCode");
sourceCode:字符最初编码格式
aimCode:需要得到的编码格式

猜你喜欢

转载自lbovinl.iteye.com/blog/2344890