Can not include javascript file from WEB-INF directory in JSP.

前端 未结 2 603
忘了有多久
忘了有多久 2021-01-27 03:03

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 \"

<         


        
相关标签:
2条回答
  • 2021-01-27 03:31
    <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

    0 讨论(0)
  • 2021-01-27 03:41

    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. :)

    0 讨论(0)
提交回复
热议问题