SmartUpload文件名乱码

来源:互联网 发布:mac系统10.13.1 编辑:程序博客网 时间:2024/06/05 16:22

保证jsp,servelt中编码全为UTF-8,如果还不行,得到文件名之后改变该字符串的编码格式

 

 

SmartUpload:

        String root="E:/file/";

response.setContentType("text/html;charset=utf-8");

request.setCharacterEncoding("utf-8");

String test=request.getParameter("test");

SmartUpload su=new SmartUpload();

su.initialize(this.getServletConfig(), request,response);

try {

su.upload();

Files files=su.getFiles();

int count=files.getCount();

for(int i=0;i<count;i++){

File f=files.getFile(i);

if(!f.isMissing()){

String name=f.getFileName();

String filename=new String(name.getBytes(),"utf-8");

 

System.out.println("name!!!!!"+name);

System.out.println("filename"+filename);

f.saveAs(root+filename, File.SAVEAS_PHYSICAL);

System.out.println(f.getFileName());

 

 

 

}

}

} catch 

原创粉丝点击