spring boot — InputStream
Posted Happy2Share
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring boot — InputStream相关的知识,希望对你有一定的参考价值。
@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的主要内容,如果未能解决你的问题,请参考以下文章
Spring boot加载外部配置文件-EnvironmentPostProcessor
Spring boot加载外部配置文件-EnvironmentPostProcessor