Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
要获取将文件添加到java web应用程序资源文件夹的正确路径吗_Java_Spring Mvc - Fatal编程技术网

要获取将文件添加到java web应用程序资源文件夹的正确路径吗

要获取将文件添加到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(); -------------------------------------------------------

我想获得资源文件夹子文件夹(resource/json)的实际路径

我试过下面提到的方法

  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"
我想在同一文件夹运行时存储文件