简体   繁体   English

如何引用另一个文件夹中存在的html中的javascript文件

[英]How to refer javascript file in html present in another folder

I have a JS file in folder /admintool/src/main/webapp/static/js/itemInventory.js 我在/admintool/src/main/webapp/static/js/itemInventory.js文件夹中有一个JS文件

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

On page load my starts with url - http://localhost:8080/admintool/selectItem/showAllItems 在页面加载中,我的开头是url- http:// localhost:8080 / admintool / selectItem / showAllItems

Inside itemInventory.ms file, when i use the below code to refer that javascript, it is not able to detect it. 在itemInventory.ms文件中,当我使用以下代码引用该javascript时,它无法检测到它。

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

In browser console, i get an error GET http://localhost:8080/admintool/selectItem/static/js/itemInventory.js net::ERR_ABORTED 在浏览器控制台中,我得到一个错误GET http:// localhost:8080 / admintool / selectItem / static / js / itemInventory.js net :: ERR_ABORTED

How do i specify the location of this JS file properly ? 如何正确指定此JS文件的位置?

Are you sure, that the links are right? 您确定链接正确吗? The link from the HTML to the JavaScript have to be: ../../static/js/itemInventory.js 从HTML到JavaScript的链接必须是:../../static/js/itemInventory.js

Ivo 伊沃

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM