首页 > 编程语言 > 详细

spring boot — InputStream

时间:2017-09-04 21:57:57      阅读:608      评论:0      收藏:0      [点我收藏+]

@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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!