且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在服务器上保存文件,java web应用程序

更新时间:2023-10-17 20:33:10

您的Web应用程序在服务器上的JVM中运行。应用程序的根文件路径通常是Tomcat服务器的文件夹。要获取此文件夹路径,您可以轻松执行以下操作:

Your web application runs within a JVM on the Server. The root file path of your application is typically the folder of your Tomcat Server. To get this folder path you can easily do the following:

String sRootPath = new File("").getAbsolutePath();

您可以将文件保存在由您创建的子文件夹中,或者您在服务器上的某处有一个额外的文件夹filesystem。

You could save your files in a subfolder created by you or you have an extra folder somewhere on the servers filesystem.