文件在项目中的位置
代码实现
package com.tests.controller; import com.tests.utils.ExcelUtil; import com.tests.utils.ExportExcel; import org.springframework.stereotype.Controller; import org.springframework.util.ClassUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @RequestMapping("/load") public class DownLoadController { @RequestMapping("/down") @ResponseBody public void down(HttpServletResponse response) throws Exception { //获取文件路径 String path = ClassUtils.getDefaultClassLoader().getResource("").getPath()+ "static/wj/工作表.xlsx"; System.out.println("path = " + path); } }
E:\ideawork\testclient\src\main\resources\static\wj\工作表.xlsx