servlet实现文件下载及中文问题

可行方法一

.....

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

//word要这么写的

response.setContentType( "application/msword;charset=gb2312 ");

String path= "E:\\测试.doc ";

String fileName= "测试.doc ";

//显示中文文件名

response.setHeader( "Content-disposition ", "attachment; filename= "

+new String( fileName.getBytes( "GBK "), "ISO8859_1 " ));

FileInputStream fis = new FileInputStream(file);

BufferedInputStream fbis = new BufferedInputStream(fis);

byte abyte0[] = new byte[1024];

int k = 0;

......

方法二

http://gflei.javaeye.com/blog/555799

你可能感兴趣的:(servlet,Blog)