Tibin Tomy Tibin Tomy - 20 days ago 9
Java Question

How can I include(load) more than one jsp files in spring mvc controller class?

How can I include(load) more than one jsp files in spring mvc conroller class?

eg:

@RequestMapping("/")
public void welcome() {

include("file1.jsp");
include("file2.jsp");
include("file3.jsp");
}

Answer

At framework level, No you cannot do it. However, there is a hack you could try.

Create an array of name of pages you need to merge. Send it as a parameter to a dummy empty page.

The dummy page does this:

<c:forEach var="page" items="${pages}">
<c:import url="${page}"></c:import>    
</c:forEach>

This will iterate all the JSP files that you wish to show as a single view.

Hope this helps. Let me know if any further help is required.