简体   繁体   中英

JSP couldnt link css files and js files

I am new to jsp. I am using Glassfish server from netbeans. Problem is that i could link my jsp file with css and javascripts. Here's the format of my file structure

Web Pages  
 --Web-Inf  
 --assets  
    --css   
     --style.css  
  --js  
 --jquery.js  
 --includes    
--header.jsp  
--footer.jsp  
--sidebar.jsp  
 --pages    
--home.jsp  
 --index.jsp    

Here's the code in my index.jsp

<%@include file="includes/header.jsp" %>

<%
    if (request.getParameter("page") == null) {
        %>
        <%@include file="pages/home.jsp" %>
        <%
    } else {
        %>

        <%
    }
%>

    <%@include file="includes/sidebar.jsp" %>
</div>

<!--Latest end-->

<%@include file="includes/footer.jsp" %>

And here's my code in header.jsp

<link href="${pageContext.request.contextPath}/assets/css/bootstrap.min.css" rel="stylesheet">

您可以使用相对URL来index.jsp

<link href="assets/css/bootstrap.min.css" rel="stylesheet">

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.

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