foreword
In the process of coding, you may need to obtain the system path anytime and anywhere. I will introduce several ways to obtain it below.
text
web project
Get the root path of the web project, that is, the webapp layer:
request.getRealPath("");
Ordinary item
Get the root path of the project:
File directory = new File("");
directory.getAbsolutePath();