项目中获取文件路径

获取webapp下面的resources文件

String cssFilePath = request.getServletContext().getRealPath("/") + File.separator+"resources/lib/bootstrap-3.3.7/css/bootstrap.min.css";
File cssFile = new File(cssFilePath);

获取resources下面的文件

File test = ResourceUtils.getFile("classpath:ehcache.xml");

或者

File path = new File(ResourceUtils.getURL("classpath:ehcache.xml").getPath());

猜你喜欢

转载自blog.csdn.net/tyf07/article/details/81837687