配置里面的路径(如果模板不更改,可以放到resource下面):
Config(从这里获取配置信息):
package com.imagedt.pawpaw.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("modelConfig")
public class ModelConfig {
@Value("${model.path}")
private String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
Controller:
@Autowired
private ModelConfig modelConfig;
/**
* 下载模板
* @return 返回excel模板
*/
@RequestMapping(value = "/downloadModel", method = RequestMethod.GET, produces ="application/json;charset=UTF-8")
public Object downloadModel(){
ResponseEntity<InputStreamResource> response = null;
try {
response = DownloadFileUtil.download(modelCo