I am new to spring framework and using jstl. I have a problem in displaying my data on jsp file. Here is my code
Controller
@RequestMapping(method = RequestMethod.GET, value = "/test")
public ModelAndView getTest(HttpServletRequest request) {
List<Place> places = PlacesService.search(types, 48.137048, 11.57538599, 10000);
for(Place place:places){
System.out.println("Name: " + place.getName());
System.out.println("Rating: " + place.getRating());
System.out.println("Categories: " + place.getTypes());
counter++;
}
ModelAndView model = new ModelAndView("test");
model.addObject("places", places);
return model;
}
In my test.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
Hello World!
<c:forEach items="${places}" var="place">
<c:out value="${place.name}"/>
<c:out value="${place.rating}"/>
<c:out value="${place.types}"/>
</c:forEach>
<c:forEach begin="6" end="15" var="val">
<c:out value="${val}"/>
</c:forEach>
</body>
</html>
For both the for loops I get ${place.name}
, ${place.rating}
, ${place.types}
and ${val}
printed. However System.print.out()
gives me the desired values.
What I am doing wrong?