Java服务器端发送文件并支持恢复?
我试图让我的java服务器传输一个Web浏览器可以下载的文件。
但是,我希望浏览器能够暂停并恢复文件传输,而不是重新开始下载。
有人知道服务器端的java代码可以解决这个问题吗?
I am trying to allow my java server to transfer a file where a web browser can download.
However, I want the browser if they pause and resume the file transfer to work and not start the download all over again.
Anyone know java code for the server side to fix this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
支持可断点下载分为两部分:
如果您提供静态资源,最好的选择是使用代理服务器(例如 Apache)来处理下载。如果代理服务器不是一个选项,那么您可能可以找到与您的应用程序服务器捆绑在一起的 Servlet;例如,Tomcat 有 DefaultServlet。此选项的缺点是它会在应用程序和应用程序服务器之间创建硬依赖关系,这可能是不可接受的。
如果您决定自己开发,我建议您查看 Apache 的 HTTP 组件。这是一个很好的 API,使处理 HTTP 请求和响应变得更加容易。
There are two parts to supporting resumable downloads:
If you're serving up a static resource your best bet is to use a proxy server, like Apache, to handle the download. If a proxy server isn't an option then you can probably find a Servlet that is bundled with your app server; for example, Tomcat has as DefaultServlet. The downside to this option is that it creates a hard dependency between your application and the application server, which may not be acceptable.
If you decide to roll your own I recommend taking a look at Apache's HTTP Components. It's a nice API that makes working with HTTP requests and responses much easier.