要取得当前web应用的绝对路径 在JSP文件中,可以通过 application.getRealPath("/"); 来得到. 在servlet中,可以通过 getServletContext().getRealPath("/"); 而在spring的controller中,由于其不是一个Servlet, 所以只能使用传入的参数request来完成这个任务. 由于request.getRealPath("/") 已经不再推荐使用.所以这儿只能使用方法: request.getSession().getServletContext().getRealPath("/");
spring的controller中取文件的绝对路径
最新推荐文章于 2023-04-01 19:46:26 发布