springmvc下载

 
 
@RequestMapping("/downloadTemplate3.action")
@ResponseBody
public void downloadTemp(HttpServletResponse response,HttpServletRequest request) throws IOException {
    response.setHeader("Content-Disposition", "attchment;filename="+new String("机顶盒资源模板.xlsx".getBytes("UTF-8"),"iso-8859-1"));
    ServletOutputStream outputStream = response.getOutputStream();
    String file = request.getSession().getServletContext().getRealPath("") + "template" + File.separator + "机顶盒资源模板.xlsx";
    FileInputStream inputStream = new FileInputStream(file);
    IOUtils.copy(inputStream, outputStream);
}
 
  
 
 

猜你喜欢

转载自www.cnblogs.com/java-diaosi/p/10641626.html