在客户端上使用正确的程序打开 webdav 链接
我们有一个基于浏览器的应用程序,集成了 webdav 服务器。 我们在 (webdav) servlet 上生成特定文档的 URL。 (https://server.com/webdav/path/to/file.doc
)
我们正在寻找一种让客户直接在适当的程序中打开这些链接的好方法。 对于 Windows 用户,IE 中的“https://server.com/webdav/path/to/excelfile.xls
”应在 MS Excel 中打开,而同一链接应在 Linux 上打开 OOCalc。
到目前为止,我们一直在使用一个小小程序,它映射扩展、操作系统和程序,并通过 Runtime.getRuntime().exec(..) 打开程序。 这种方法在 Ms-Windows 上工作得还不错,但在 Linux 和 Mac 客户端上就会出现问题,而且非常不灵活。
有更好的方法吗?
We have a browser based application which integrates a webdav server. We generate URLs to specific documents on our (webdav) servlet. (https://server.com/webdav/path/to/file.doc
)
What we are looking for is a good way for our clients to open these links directly in the appropriate program. I.E. for a windows user, "https://server.com/webdav/path/to/excelfile.xls
" should open in MS Excel, while the same link should open OOCalc on Linux.
So far, we've been using a small applet which maps has extensions, OS's, and programs and opens the program through Runtime.getRuntime().exec(..)
. This approach works somewhat ok on Ms-Windows but is problematic on Linux and mac clients and is also quite inflexible.
Is there any better way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这不是 java.awt.Desktop 类的设计目的吗?
我说“专为”而设计,因为它在很多事情上做得不好或不正确,但它确实对某些事情有用。 它缺少“打开方式”选项,就像操作系统必须提示您在没有注册任何内容的情况下应该使用什么方式打开文档一样。
它可能会将 url 解释为 Web url,打开浏览器,然后浏览器可能会委托打开文件? 在这种情况下,您必须将文档下载到临时文件,然后使用desktop.open?
Isn't this what tha java.awt.Desktop class was designed for?
I say "Designed for" because there are a lot of things that it doesn't do well or correctly, but it does work for some things. Its missing the option for "open with", like the operating system has to prompt you for what you should open a document with if there's nothing registered for it.
It might interpret the url as a web url, open the browser, and then the browser might delegate to opening the file? in that case you'd have to download the document to a temp file and then use desktop.open?
如果将文件的 MIME 类型设置为正确的格式,所有浏览器都应该能够处理它们。 然后,用户可以决定对该类型采取默认操作(打开 acrobat、word、excel、记事本)或选择自定义操作。
If you set the MIME types of the files to the proper format, all browsers should be able to handle them. The user can then decide to take the default action for that type(open acrobat, word, excel, notepad) or pick a custom one.
如今,它在 Internet Explorer 10/11 中运行良好。 但您必须添加注册表项才能允许 Office 以读/写方式打开从浏览器传递的文档。 注册表键值如下:
请参阅此文章了解有关设置密钥的信息:
http://social.technet.microsoft.com/Forums/office/en-US/06fedd90-4889-45ca-949d-60b76d74dd15/ms-word-open-document-readonly-with-WebDAV
It works great in Internet Explorer 10/11 these days. But you will have to add a registry key in order to allow Office to open documents handed off from a browser as read/write. The registry key is as follows:
See this article for information about setting the key:
http://social.technet.microsoft.com/Forums/office/en-US/06fedd90-4889-45ca-949d-60b76d74dd15/ms-word-open-document-readonly-with-WebDAV
不幸的是,小程序是目前唯一的解决方案。 但在极少数情况下,我们会使用
"SharePoint.OpenDocuments"
和'application/x-sharepoint'
插件。 您可以在此处与您的解决方案进行比较。Unfortunately applet is the only solution for now. But in rare cases we use
"SharePoint.OpenDocuments"
and'application/x-sharepoint'
plugins. You can compare with your solution here.