简体   繁体   English

如何使服务器上的文件可用于客户端Web浏览器(使用Java编写的服务器)

[英]How do I make files on my server available to client webbrowser, server written in Java

My Java application is using jetty running an embedded server, the idea being my software can then be controlled by a browser from a phone/ipad with the server running on PC/Mac ecetera. 我的Java应用程序使用的是运行嵌入式服务器的jetty,其想法是,我的软件然后可以由手机/ ipad上的浏览器控制,并且服务器可以在PC / Mac ecetera上运行。

I want the user to be able to browse folders on the server from webpage within their browser, not on their client so I was thinking that webdav might be the answer, but how do I even get started with this. 我希望用户能够从其浏览器内的网页浏览服务器上的文件夹, 而不是在客户端上浏览,因此我一直认为webdav可能是答案,但是我什至开始使用它。 All I want them to be able to do is view a browser tree of folders on the server and pick a folder, this folder is then stored in a Form text field and submitted to the server. 我希望他们能够做的就是查看服务器上文件夹的浏览器树并选择一个文件夹,然后将该文件夹存储在“表单”文本字段中并提交给服务器。 That is all I need it to do. 这就是我需要做的。

So currently you can use file input type to allow users to browse for files on their computer, but I need the same functionality but for browsing files on the server. 因此,当前您可以使用文件输入类型来允许用户浏览其计算机上的文件,但是除了浏览服务器上的文件外,我需要相同的功能。

<input type="file" name="img">

I realize this is not out of the box behaviour but I have seen it implemented before so how is it done ? 我意识到这不是开箱即用的行为,但我之前已经看到了它的实现,那么它是如何完成的呢?

It seems the server would have to provide the file structure, I could try and create this in my backend but hopefully there is something that already done this. 看来服务器必须提供文件结构,我可以尝试在后端创建此文件结构,但希望已经做了一些事情。 Then it has to be rendered on the front-end I assume there is already something for rendering a file structure ? 然后必须在前端渲染它,我假设已经有一些东西可以渲染文件结构了?

I found this question Server Side File Browsing which asks essentially the same question, however it is very old and I believe outdated. 我发现了这个问题, 服务器端文件浏览本质上是一个相同的问题,但是它已经很老了,我认为已经过时了。

The solution I am implementing is to use jsTree on the client in ajax mode to contact the server as the user clicks on nodes so it only gets the data as required. 我正在实现的解决方案是在用户单击节点时,以ajax模式在客户端上使用jsTree与服务器联系,以便仅根据需要获取数据。 The server code makes use of java FileVisitor class to construct the required part of the folder tree and return it jsTree in json format. 服务器代码利用java FileVisitor类构造文件夹树的必需部分,并以json格式将其返回jsTree。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在客户端而不是服务器端将我的哈巴狗文件渲染到 html - How do I render my pug files to html on the client-side instead of server-side 如何将数据服务器(用JAVA编写)发送到客户端(用Node.js编写) - How to send data server (written in JAVA) to client (Written in Node.js) 如何在Meteor上使服务器可以访问文本文件 - How do I make text files accessible to the server on Meteor 如何从外部请求使本地服务器可用? - How can I make my localhost server available from external requests? 如何使我的 typescript 库的声明文件可安装在 @types/mylibrary - How do I make my declaration files for the typescript library available for install at @types/mylibrary 如何让我的服务器完成所有加载和 javascript 然后服务器页面准备就绪 - How do I make my server do all the loading and javascript and then server the page all ready 如何通过 HTML 格式的服务器上的网页将文件上传到我的 Web 服务器? - How do I Upload Files to my Web Server Through a Webpage on the Server in HTML? 我如何让我的快递服务器从我的React客户端应用程序获取请求? - How do I get my express server to GET a request from my React client app? 如何将客户端的 req.body 与服务器端的三个变量之一匹配? - How do I match my req.body from the client to one of three variables on my server side? 使用Java的Dropbox Chooser从Dropbox选取文件后,如何将文件存储在服务器中? - How can I store the files in my server after picking the files from dropbox with the dropbox Chooser using java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM