Reputation: 24318
I have created a view and its working well but i now need to Include another JSP inside the page.
Considering my views are installed in the protected area of WEB-INF/Views (hence its not available in my resources directory where my imgs, css are)
I have tried using
<%@ include file="/views/shared/items/NewItem.jsp" %>
And it always gives me FileNotFound, taking into consideration that my NewItem.jsp is installed with my other views (i.e. NOT accesible via the normal routes but controlled by controllers) how can i include a JSP files that is installed next to my view
If i take out the "include file" my view renders without issues.
I am sure i am missing something here?
Thanks in advance
Upvotes: 4
Views: 25797
Reputation: 41
Better to user
<jsp:include />
instead of
<%@ include />
and send request to controller and controller will handle view
Sending request to contoller
<jsp:include page="${request.contextPath}/newItem"></jsp:include>
Controller
@RequestMapping(method = RequestMethod.GET, value = "newItem")
public String newItem(Model model) {
return "shared/items/NewItem";
}
Upvotes: 4
Reputation: 691993
If NewItem.jsp
is in /WEB-INF/views/shared/items/NewItem.jsp
, then you have to use this path when incuding it:
<%@ include file="/WEB-INF/views/shared/items/NewItem.jsp" %>
Upvotes: 14