【问题标题】:How to refer javascript file in html present in another folder如何在另一个文件夹中的html中引用javascript文件
【发布时间】:2018-03-11 17:03:06
【问题描述】:

我在文件夹中有一个 JS 文件 /admintool/src/main/webapp/static/js/itemInventory.js

我在文件夹中有 html 文件 /admintool/src/main/webapp/WEB-INF/templates/itemInventory.ms

在页面加载我的开头是 url - http://localhost:8080/admintool/selectItem/showAllItems

在 itemInventory.ms 文件中,当我使用以下代码引用该 javascript 时,它无法检测到它。

<script src="static/js/itemInventory.js"></script>

在浏览器控制台中,我收到一个错误 GEThttp://localhost:8080/admintool/selectItem/static/js/itemInventory.jsnet::ERR_ABORTED

如何正确指定这个JS文件的位置?

【问题讨论】:

    标签: javascript html web


    【解决方案1】:

    您确定链接正确吗?从 HTML 到 JavaScript 的链接必须是: ../../static/js/itemInventory.js

    伊沃

    【讨论】:

      猜你喜欢
      • 2022-07-06
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-07
      • 2023-03-30
      • 1970-01-01
      • 2015-12-18
      相关资源
      最近更新 更多