重定向可以静态资源再网页打开,减少了传统的文件下载。用到一个类ModelAndView
@GetMapping("/downProductflowTempalte")
public ModelAndView downProductflowTempalte() throws IOException {
String redirect="";
//这里直接给出相对路径,中文名字记得百度一下URL中文转码
redirect="redirect:/template/%E4%BA%A7%E5%93%81%E6%B5%81%E5%90%91%E8%A1%A8%E6%A8%A1%E6%9D%BF.xlsx";
ModelAndView model = new ModelAndView(redirect);
return model;
}
就这样访问后直接再浏览器展示,完成了下载工作