尝试访问磁盘上的文件时 url 无效

发布于 2024-12-14 06:31:37 字数 554 浏览 4 评论 0原文

您好,我正在使用 setDataURL("map xml 路径") 渲染地图, 目前,当我给出一个有效 URL 的路径时,地图才会加载。 如果我将该路径指定为磁盘位置,则它不起作用,因为它只是将此路径附加到基本 URL,这使其成为无效 URL。 所以如果路径是 /myapp/js/my1.xml - 它的工作原理是我的 js 文件夹位于 web-app 目录中,所以 http://localhost:xxx/myapp/js/my1.xml 是有效的

如果路径类似于 C:/xmls/my1.xml, - 因为 http://localhost:xxx/myapp/C:/xmls/my1.xml是无效的网址。 但由于我们正在部署战争,我们希望将 XML 保留在 Web 应用程序之外,因此如何在 setDataURL() 方法中设置路径。

谢谢&问候 普里扬克

Hi I am rendering a map using setDataURL("path to map xml"),
currently when I give a path which a valid URL only then does the Map load.
If I give the path as a disk location , it doesnt work since it just appends this path to the base URL which makes it an invalid URL.
so if the path is /myapp/js/my1.xml - it works as I have my js folder in web-app directory so http://localhost:xxx/myapp/js/my1.xml is valid

if the path is like C:/xmls/my1.xml - it doesnt work since http://localhost:xxx/myapp/C:/xmls/my1.xml is invalid URL.
but since we are deploying a war we want to keep the XML outside the web-app , how do I set the path in setDataURL() method.

Thanks & Regards
Priyank

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏别ゝ 2024-12-21 06:31:37

主要您可以尝试使用 file:/// 协议,但我担心如果您的应用程序在网络服务器中运行,这可能没有多大帮助。

这可能会导致跨域问题并且文件内容将被阻止。

Primarily you can try using file:/// protocol, but I fear that might not of much help if you application is running in a webserver.

This is likely to cause a cross domain issue and the file content will get blocked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文