How about! I am doing a small application of Spring (I am learning) and I have found that, when passing as a parameter a List object in sight (JSP), the cycle forEach
does not work as it should. Actually if one searches in the HTML the objects appear, but I do not know if I am accessing its attributes of the object well, although I know that they are well defined, this is my code:
<table class="table table-bordered">
<thead>
<tr>
<th>Project Name</th><th>Sponsor Name</th><th>Description</th>
</tr>
</thead>
<tbody>
<c:forEach items="${projects}" var="project">
<tr>
<td>${project.name}</td><td>${project.sponsor}</td><td>${project.description}</td>
</tr>
</c:forEach>
</tbody>
</table>
This is the output in the HTML:
<table class="table table-bordered">
<thead>
<tr>
<th>Project Name</th><th>Sponsor Name</th><th>Description</th>
</tr>
</thead>
<tbody>
<c:forEach items="[com.pyxis.mvc.data.entities.Project@327b6991, com.pyxis.mvc.data.entities.Project@60e256f9, com.pyxis.mvc.data.entities.Project@6412e13d]" var="project">
<tr>
<td></td><td></td><td></td>
</tr>
</c:forEach>
</tbody>
</table>
I have added the taglib <c:>
directly to the JSP but it gives me a compilation error, when I remove it compiles without problems. I'm using NetBeans and then I can not think of anything, I hope you can help me, regards!
This way I add my object to the view:
@Autowired
private ProjectService projectService;
@RequestMapping(value = "project/find", method=RequestMethod.GET)
public String find(Model model){
model.addAttribute("projects", this.projectService.findAll());
return "ProjectFindView";
}