要获取将文件添加到java web应用程序资源文件夹的正确路径吗
我想获得资源文件夹子文件夹(resource/json)的实际路径 我试过下面提到的方法要获取将文件添加到java web应用程序资源文件夹的正确路径吗,java,spring-mvc,Java,Spring Mvc,我想获得资源文件夹子文件夹(resource/json)的实际路径 我试过下面提到的方法 URL resource = Helper.class.getResource("/json"); String _path = resource.getPath(); File file = new File(resource.toURI()).getAbsoluteFile(); -------------------------------------------------------
URL resource = Helper.class.getResource("/json");
String _path = resource.getPath();
File file = new File(resource.toURI()).getAbsoluteFile();
------------------------------------------------------------
Resource rc = new ClassPathResource("/json");
String res = rc.getFile().getAbsolutePath();
-------------------------------------------------------------
ServletContext context = req.getServletContext();
String ctx = context.getRealPath("/Test/WEB-INF/classes/json");
我只获取eclipse临时目录路径
"/home/sanjay/test/workspace/testworkspace1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Test/WEB-INF/classes/json"
我想在同一文件夹运行时存储文件