try{
String html = “<p></p>”;
String fileName=template.getString("name")+".doc";//保存窗口中显示的文件名
getResponse().reset();
getResponse().setCharacterEncoding("utf-8");
getResponse().setContentType("application/msword;charset=gb2312");
getResponse().setHeader("Content-Disposition", "attachment; filename=\""+new String(fileName.getBytes("UTF-8"),"ISO-8859-1")+"\"");
ServletOutputStream out = getResponse().getOutputStream();
out.write(html.getBytes("utf-8"));
getResponse().flushBuffer();
out.close();
}catch(Exception e){
e.printStackTrace();
}
servlet下载文件,从html转为word下载
猜你喜欢
转载自yangzy1029.iteye.com/blog/2213326
今日推荐
周排行