关于文件下载中文乱码设置
ISO8859-1的方式。不过该编码只支持简体中文.
?
例子:
else if("photos".equals(action))
??{
???File file=new File("f://陈少军.jpg");
???String ss=file.getName();
???response.setCharacterEncoding("UTF-8");???
???
????????? response.setContentType("multipart/form-data;charset=Utf-8");???
??????
????????? response.setHeader("Content-Disposition", "attachment;fileName="+java.net.URLEncoder.encode(ss,"UTF-8"));??
????
//???response.addHeader("content-type", "application/x-msdownload;");
//???response.addHeader("Content-Disposition","attachment;filename="+ss);
//???response.addHeader("content-length", "");
???
???InputStream in=new FileInputStream(file);
???OutputStream out=response.getOutputStream();
???int len=0;
???byte [] buf=new byte[1024];
???while((len=in.read(buf))!=-1)
???{
????out.write(buf,0,len);
???}
?
???in.close();
?????? out.close();
???return null;
??}
??