1

 ServletRequestAttributes att=(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
  HttpServletRequest request = att.getRequest();
  request.getSession().getServletContext().getRealPath("/") ;

 

2

String resoucePath=当前类.class.getResource("/").getPath();
String webappsDir=(new File(resoucePath,"../../")).getCanonicalPath();

 

3 在propertie文件里写死路径

去读取

Properties properties = new Properties();
InputStream in =当前类.class.getClassLoader().getResourceAsStream("demo.properties");
properties.load(in);
String webapps = properties.getProperty("path");

 

相关文章:

  • 2021-12-09
  • 2022-02-07
  • 2022-02-02
  • 2022-12-23
  • 2021-11-04
  • 2022-02-07
  • 2021-06-17
  • 2021-07-28
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2022-02-07
相关资源
相似解决方案