protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String path = this.getServletContext().getRealPath("/WEB-INF/classes/1.png");
System.out.println("文件下载路径为:"+path);
String fileName = path.substring(path.lastIndexOf("//")+1);
resp.setHeader("Content-Disposition", "attachment; " + "filename="+fileName);
FileInputStream is = new FileInputStream(path);
ServletOutputStream os = resp.getOutputStream();
int len = 0;
byte[]flush =new byte[1024];
while ((is.read(flush))!=-1){
os.write(flush,0,len);
}
}