链接到 Web 应用程序中的本地内容 [英] Linking to local content in a web application
问题描述
我正在开发旧应用程序的替代应用程序.由于遗留应用程序的某些设计限制,附件"在我们的数据库中存储为字符串路径(通常文件存储在 Windows 共享驱动器上).然后,遗留应用程序可以通过打开 Windows 命令外壳并执行给定路径来打开"附件.
I am working on a replacement application to a legacy application. Due to certain design limitations of the legacy application, 'attachments' are stored as a String path in our database (generally files stored on a windows shared drive). The legacy application can then 'open' the attachments by opening a windows command shell and executing the given path.
旧的 (Oracle Forms) 应用程序正在被基于 JSF 的 J2EE Web 应用程序淘汰.新应用程序需要能够以某种方式打开"或链接到这些旧附件.这甚至可能吗?我曾尝试使用 file://URL,但使用它们有很多注意事项.它们仅适用于 IE 中的远程主机,firefox/chrome(以及我假设的其他现代浏览器)阻止本地文件 URL.
The legacy (Oracle Forms) application is being phased out by a JSF based J2EE web application. The new application needs to be able to 'open' or link to these legacy attachments somehow. Is this even possible? I have attempted to use file:// URLs, but there are lot of caveats with using them. They only work on remote hosts in IE, firefox/chrome (and other modern browser I assume) prevent local file URLs.
仅在 IE 上工作是可以使用此特定功能的东西.我进一步遇到了带空格的文件路径问题.出于某种原因,如果 IE 遇到一个包含空格的文件路径,比如
Working only on IE is something that can be lived with for this particular feature. I further ran into an issue with file paths with spaces. For some reason if IE encounters a filepath with spaces in it, say
C:Documents and Settingsuser123My Documents estingsomeFile.txt
它拒绝打开那个链接.浏览器会自动用其 URL 编码的%20"替换空格 ("").
it refuses to open that link. The browser automatically replaces the spaces (' ') with its URL Encoded '%20'.
我正在尝试的关联链接如下所示:
The associated link I am attempting looks like:
<a href="file:///C:Documents and Settingsuser123My Documents estingsomeFile.txt">link</a>
我错过了一些简单的东西吗?或者有没有更简单的方法?
Is there something simple to this I am missing? Or is there any easier way of doing this?
我不太确定要标记什么,因此请随时根据需要重新标记.
I wasn't quite sure what to tag this as so feel free to retag as necessary.
推荐答案
经过一些广泛的测试,我得出了以下结论:
After some extensive testing I have reached the following conclusions:
- 只有 IE 会打开来自远程主机的页面上的 file://链接,其他浏览器会完全阻止它们,当用户点击它们时不会发生任何事情.
- IE 只会打开 file://URL 指向驻留在网络驱动器上的文件
- 如果用户单击指向用户本地驱动器上文件的 file://链接,则不会发生任何事情,也不会出现错误.
希望这能帮助其他正在寻找文件 url 信息的人.
Hopefully this helps someone else out who's looking for information on file urls.
这篇关于链接到 Web 应用程序中的本地内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!