jingyunyb

1、项目根目录(tomcat、web项目)

String path = ServletActionContext.getServletContext().getRealPath("");
System.out.println(path);

想要获取图片存放的位置,则为String path = ServletActionContext.getServletContext().getRealPath("images");


      

2、java代码编译后class文件所在的路径(classpath路径)
String serverDir = this.getClass().getClassLoader().getResource("").getPath();
System.out.println(serverDir);

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2021-08-29
  • 2022-02-07
  • 2021-11-29
  • 2021-07-06
  • 2021-11-27
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
相关资源
相似解决方案