如何从jsp上传文件夹中的所有内容
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先您需要认识到,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.