问题
How to include a file in the following folder WEB-INF\includes\header.js in jsp using tomcat. I have the included the following in jsp file but it does not work "
<script type="text/javascript" src="WEB-INF/includes/header.js"></script>
". It is not getting the header.js and when i view source and try to click on the src link it says resource not found 404 error.
回答1:
<script type="text/javascript">
<%@include file="../foo.js" %>
</script>
foo.js is under WEB-INF/jsp and the file include it is under WEB-INF/jsp/common
回答2:
Put a "/"
before "WEB-INF"
like this,
<script type="text/javascript" src='<c:url value="/WEB-INF/includes/header.js"/>'></script>
and it will work fine. :)
来源:https://stackoverflow.com/questions/8391467/can-not-include-javascript-file-from-web-inf-directory-in-jsp