You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

资源加载404错误:JS文件与图片无法正常加载求助

资源加载404错误:JS文件与图片无法正常加载求助

我现在遇到了资源加载的链接问题,怎么都搞不懂原因在哪里😭

我在/component文件夹里有个song-history.js文件,尝试这样引入:

<script src="/components/song-history.js" type="text/javascript"></script>

结果报错:

GET http://localhost:8080/components/song-history.js net::ERR_ABORTED 404 (Not Found)

图片的情况也一样,/icons文件夹里的图片我这样引用:

<img id="img" src="/icons/up.png">

得到的报错是:

GET http://localhost:8080/icons/equal.png 404 (Not Found)

我的目录结构是这样的:
根目录下包含 components、icons、META-INF、WEB-INF 这几个文件夹,还有 index.jsp 文件。

我试过重命名文件夹、移动文件夹位置、把文件移到根目录——各种办法都试过了,完全没用。
直接在浏览器里访问链接比如 http://localhost:8080/icons/re.png 时,还会出现这个奇怪的提示:

Type Status Report
Message JSP file [/icons/main.jsp] not found
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

我都搞不懂为什么它要在那个路径找main.jsp...

有没有人能帮我解决一下呀?😊


更新:
我把JS的引用方式改成了下面这样:

<script type="text/javascript"><%@include file="/components/song-history.js"%></script>

这样JS文件能正常加载了,但还是不知道第一种方式哪里出问题了,而且图片的加载问题也还没解决。

备注:内容来源于stack exchange,提问作者egor-n

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 18:43:09