0
votes

I have Spring MVC with spring boot,also I use JSP file for the View. I have already use the JSP and JSTL library

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

I have no problem with the JSP and JSTL syntax for example

<c:set var="heading" scope="page" value="${0}" />

 <c:forEach var="menuGroup" items="${menuGroups}">
   <c:if test="${menuGroup.headingId != heading}">
       <c:if test="${menuGroup.headingIsDisplayed == 1}">
            <li class="menu-title text-white">${menuGroup.headingTitle}</li>
    </c:if> 
    <c:set var="heading" scope="page" value="${menuGroup.headingId}" />

 </c:if>

    <li class="has_sub">
     <a href="index.html" class="waves-effect">
        <i class="ti-home"></i>
        <span> ${menuGroup.menuGroupTitle}</span>
        <span class="pull-right"><i class="mdi mdi-chevron-right"></i> 
   </span>
    </a>

    <ul class="list-unstyled">

        <c:forEach var="menu" items="${menuGroup.menus}">

            <li><a href="${menu.menuPath}">${menu.menuTitle}</a></li>
        </c:forEach>

    </ul>
  </li>


 </c:forEach>

But when I use the JSP Include tag

      <jsp:include page="sidemenu.jsp" flush="true"></jsp:include>

It's not working!, the content from the sidemenu JSP file is not included in the Page and also there is no error message at all.

Is there any page setting or configuration that I missed? Or the tag Cannot be used in Spring Boot MVC project ??

3

3 Answers

3
votes

The above should work perfectly. the only issue may be with the sidemenu.jsp file location.

So try to use something like below by helping to find jsp page which you are going to include.

<jsp:include page="/WEB-INF/JSPs/header/navigation.jsp"></jsp:include>

OR

<jsp:include page="../sidemenu.jsp"></jsp:include> //if one upper directory

Also refer include-jsps-file-from-another-folder

2
votes

First, you need to find the actual path of your sidemenu.jsp.
Then you have to use this path when including it. Like this,

<jsp:include page="../views/jsp/sidemenu.jsp" flush="true"/>
0
votes

Why don't you use: <%@ include file=/included-file.jsp" %>