HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
HttpSession session =ServletActionContext.getRequest().getSession();
String fp=(String)session.getAttribute("rolePriv");
String files="";
if(fp.equals("3")){
files="jyba_sj.doc";
}
if(fp.equals("4")){
files="jyba_pj.doc";
}
if(fp.equals("5")){
files="jyba_scqy.doc";
}
if(fp.equals("6")){
files="jyba_jyqy.doc";
}
String path = ServletActionContext.getServletContext().getRealPath("/")+ "files" + File.separator+files;
response.setHeader("Content-disposition", "attachment; filename="+ URLEncoder.encode("帮助文件.doc", "utf-8"));// 设定输出文件头
InputStream in = new FileInputStream(new File(path));
OutputStream out = response.getOutputStream();
int i=0;
byte []b = new byte[1024];
while ((i = in.read(b)) != -1) {
out.write(b, 0, i);
}
in.close();
out.flush();
out.close();
return null;