码迷,mamicode.com
首页 > 编程语言 > 详细

spring boot — InputStream

时间:2017-09-04 22:40:30      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:str   spring   ide   attach   ret   led   inpu   request   https   

@Component
public class TextFileDownloadView extends AbstractFileDownloadView {

@Override
protected InputStream getInputStream(Map<String, Object> model,
HttpServletRequest request) throws IOException {
Resource resource = new ClassPathResource("abc.txt");
return resource.getInputStream();
}

@Override
protected void addResponseHeader(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response) {
response.setHeader("Content-Disposition", "attachment; filename=abc.txt");
response.setContentType("text/plain");

}
}

@RequestMapping(value = "/downloadTxt", method = RequestMethod.GET)
public String downloadTxt1() {
return "textFileDownloadView";
}

 

Originate from http://rensanning.iteye.com/blog/2356942

spring boot — InputStream

标签:str   spring   ide   attach   ret   led   inpu   request   https   

原文地址:http://www.cnblogs.com/luffystory/p/7475963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!