Reputation: 10960
My current MVC application in Spring is a classical one - controller returns view name to render, then *.jsp file is rendered to the browser. Simple and bullet-proof :)
What I want to do now is to update parts of the page using AJAX.
Part of the page should be handled by method in controller, something like "taskList" would render readty-to-include html with list of tasks.
It's all fine and dandy with ajax itself - I just create holding div in page and populate it with html from that request.
Now the question: Is there a way to include that html in page on server side? Something like (warning: pseudocode :))
<div id="taskListHolder">
<someSpringtag:include 'taskList' />
</div>
Basically I want to include html from one controller response in another. So in case of first page load no AJAX is necessary and it would also work when JS is disabled.
What are the best practices to do such a thing?
Thanks! Leonti
Upvotes: 3
Views: 2022
Reputation: 6848
Try using Core JSTL tag library:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<div id="taskListHolder">
<c:import url="http://your-link-to-ajax-list"/>
</div>
</body>
</html>
Upvotes: 1