如何从jsp上传文件夹中的所有内容

发布于 2024-10-01 03:29:42 字数 141 浏览 1 评论 0原文

我正在尝试使用 jsp 和 servlet 将文件夹中的所有内容上传到服务器中的另一个文件夹。我已经有了一个 FileUpload,但您可能知道我只能选择一个文件。有什么可能的方法可以做到这一点吗?能够从 jsp 中选择文件夹而不是单个文件?

提前致谢

i'm trying to upload all of the contents in a folder to another folder in my server using jsp and servlets. I already got one FileUpload but as you may know i can only choose a single file. Is there some possible way to do this?? To be able to choose a folder instead of a single file from a jsp?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过潦 2024-10-08 03:29:42

首先您需要认识到,JSP 只是一种基于 Java 的视图技术,它允许您使用 Java 控制 HTML/CSS/JS 的输出。毕竟,最终出现在网络浏览器中的只是 HTML/CSS/JS。在 HTML 中,无法选择要上传的文件夹。 HTML 根本就不是为此设计的。 JSP对此无能为力。

最好的选择是使用 JFileChooser 设置为文件夹选择。您可以按照通常的 HTML 方式将其嵌入到 JSP 页面中。有几个可用的第 3 方小程序,您只需下载/购买并将其嵌入到 JSP 中,但不幸的是它们都不是免费软件。

First thing you need to realize is that JSP is just a Java based view technology which allows you to control the output of HTML/CSS/JS using Java. After all, it's just HTML/CSS/JS which ends up in the webbrowser. In HTML, there's no possibility to select a folder for upload. The HTML <input type="file"> simply isn't designed for that. JSP can't do much about it.

Your best bet is creating a Java applet utilizing JFileChooser which is set to folder selection. You can embed it in the JSP page the usual HTML way. There are several 3rd party applets available which you could just download/buy and embed it in the JSP, but unfortunately none of them is freeware.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文