I used to have a jsp page with some EL/JSTL Tags. Now I want to rewrite it in plain HTML and JavaScript (because it will be placed in a CMS).
The loading of my JavaScript fails, because I used to load it with something like this
<script
src="${pageContext.request.contextPath}/external/jquery-3.3.1.min.js"></script>
Of course, I could try to hard code the real path, but I want a bit flexibility. So is there an equivalent of pageContext.request.contextPath
in plain html?
Not sure if this helps you. Try using a CDN:
<script
src="http://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
It's faster, secure and doesn't need to be downloaded too. Also, you can use relative paths from the domain name, say:
<script
src="/assets/external/jquery-3.3.1.min.js"></script>
The above works if you know where exactly the script resides.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.