package com.cn.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@RestController
@RequestMapping("download")
public class DownloadController {
@GetMapping("excel")
public void download( HttpServletResponse response)throws Exception {
try {
//String path = "D:/file/pengke.docx"; 本地文件路径
//资源文件路径
String path = getClass().getClassLoader().getResource("templates/template.docx").getPath();
System.out.println(path);
File file = new File(path);
// 取得文件名。
String filename = file.getName();
// 取得文件的后缀名。
String ext = filename.substring(filename.lastIndexOf(".