引言 在web项目开发过程中,可能会经常遇到要获取项目根路径的情况,那接下来我就总结一下,java中获取项目根路径的 种方法,主要是通过thisClass和System,线程和request等方法。 :this.getClass .getResource :file.getCanonicalPath :this.getClass .getClassLoader :System.getPropert ...
2019-05-24 09:31 0 10860 推荐指数:
java中获取类加载路径和项目根路径的5种方法 ...
package com.annotation.action;import java.io.File;import java.io.IOException;import java.net.URL;public class MyPathDemo { public static void main ...
如Web项目名称为Demo,那么${#httpServletRequest.getContextPath()}获取到的值为Demo ...
import java.io.File; import java.io.IOException; import java.net.URL; public class MyUrlDemo { public static void main(String[] args ...