public void downloadLocalTemplate(String fileName, HttpServletResponse response) {
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
try {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("exceltemplate/" + fileName);
OutputStream os = response.getOutputStream();
byte[] b = new byte[2048];
int length;
while ((length = inputStream.read(b)) > 0) {
os.write(b, 0, length);
}
os.close();
inputStream.close();
} catch (FileNotFoundException e) {
log.error(e.getMessage(), e);
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
getOutputStream() has already been called for this response
不能既调用response.getOutputStream(),又调用response.getWriter(),有冲突