public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ServletContext sc = getServletContext();
String imgPath = "/国家奖学金.jpg";
String realPath = sc.getRealPath(imgPath);
FileInputStream fis = new FileInputStream(realPath);
String fileName = realPath.substring(realPath.lastIndexOf("\\")+1);
//对文件名进行编码
response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(fileName, "UTF-8"));
ServletOutputStream out = response.getOutputStream();
byte[] buf = new byte[1024];
int len = -1;
while((len=fis.read(buf))!=-1){
out.write(buf, 0, len);
}
fis.close();
out.flush();
out.close();
}