JSTL appears in HTML

4

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="[[email protected], [email protected], [email protected]]" 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";
}
    
asked by Breid 02.05.2016 в 16:22
source

1 answer

3

I have managed to make my code work, if it happens just look at this tablet and add your dependency to the pom.xml and its jsp file.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
answered by 02.05.2016 в 21:27