尝试访问磁盘上的文件时 url 无效
您好,我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要您可以尝试使用 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.