大网数据广告活动
网站运营与故障问答

Cannot load local resource

· 52CE 我爱测

In spring project, I am generating some pdf file automatically in my application and storing it in $CATALINA_BASE in tomcat server. The path is : D:\Project_Local\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpw…

问题原文

原帖链接 · Babanna Duggani · CC BY-SA 3.0

In spring project, I am generating some pdf file automatically in my application and storing it in $CATALINA_BASE in tomcat server. The path is :

D:\Project_Local\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\happyweb\images\User.pdf  

I have given one hyperlink on webpage to access this file. But when I click on that link it is giving error in Chrome console as below:

 Not allowed to load local resource:D:\Project_Local\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\happyweb\images\User.pdf

What is the problem and how so resolve that?

已采纳解答

原帖链接 · dan · CC BY-SA 3.0

I have given one hyperlink on webpage to access this file.

When you provide the local path to a file in your webpages, as covered here, you're making the assumption that the file exists on the client's computer or device, not on your server.

Instead of using a local file path in your hyperlink like:

D:\Project_Local\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\happyweb\images\User.pdf

you should store the file in a directory that's served by your web server, and then use a URL to the file that includes your hostname, like:

http://myserver.com/happyweb/images/User.pdf

If you do intend to serve a file locally (i.e., on the same computer), then you should use the file URI scheme. On Windows, that would look like:

file:///d:/path/to/User.pdf

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2013-10-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。