在服务器上保存文件,java web应用程序 [英] save file on server, java web application

查看:218
本文介绍了在服务器上保存文件,java web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自我的Web应用程序(vaadin)我生成XML文件并希望将这些文件存储在服务器上。我做了:

from my web application (vaadin) I generate XML files and want to store these files on the server. I did:

context.getHttpSession().getServletContext().getRealPath("/");

我在tomcat上运行web应用并设法将文件保存到

I run the web app on tomcat and managed to save the file to the app folder under

.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/my_app_folder/

与META-INF,WEB-INF和VAADIN文件夹处于同一级别。如果我想将文件保存在服务器存储上并将文件路径保存在数据库中,我应该在哪里保存文件?谢谢

on the same level with META-INF, WEB-INF and VAADIN folder. If I want to save the file on server storage and save the path of the file on the database, where should I save the files? Thank you

推荐答案

您的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.

这篇关于在服务器上保存文件,java web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆