How to include a controller from jsp page

后端 未结 2 1804
轻奢々
轻奢々 2021-01-21 13:03

I\'m using Spring MVC.

I want to include menu page (named menu.jsp) with a controller (named MenuController) to my main page. If I call http://localhost:8080/myWeb/menu.

相关标签:
2条回答
  • 2021-01-21 13:55

    Try using <%@ include file="menu.jsp" %> or <jsp:include page="menu.jsp" />

    By the way, no controller interferes here - this happens purely in the view.

    On the other hand, if you want your controller to set some data required in the menu, then you should indeed use <c:import />. Not however that the path there is relative to the current page. So make sure it is correct.

    0 讨论(0)
  • 2021-01-21 14:02

    I just discovered today you can trigger the controller by referencing the relative Spring url in the include.

    <jsp:include page="/ConrollerRequestMapping/your/method/request/mapping"/>
    
    0 讨论(0)
提交回复
热议问题