Creating View

We have created data access objects for Course and a Controller. Let's see how we can call them from a View. Views in Spring are typically JSPs. Create a JSP (name it courses.jsp) in the src/main/webapp/WEB-INF/views folder. This is the folder that we configured in servlet-context.xml to hold the Spring View files.

Add the JSTL tag library in courses.jsp:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

The markup code to display courses is very simple; we make use of the courses variable, which is made available in the Model from the CourseController.getCourses method and displays values using JSTL expressions:

<table> <tr> <th>Id</th> <th>Name</th> <th>Credits</th> <th></th> </tr> <c:forEach items="${courses}" ...

Get Java EE 8 Development with Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.