Java / JSTL - Table listing with c: forEach

0

I've tried listing database information on a JSP page using the <c:forEach> tag, but I'm not getting any return values.

ADO:

    @Override
public List<Livro> consultar() throws SQLException{

            List<Livro> livros = new ArrayList<Livro>();
            try {
            String sql = "SELECT * FROM liros WHERE st_ativo=1";
            Statement stmt = con.createStatement();
            ResultSet result = stmt.executeQuery(sql);

            while(result.next()) {
                Livro li = new Livro();
                li.setTitulo(result.getString("titulo"));
                li.setPaginas(result.getInt("paginas"));
                li.setAutor(result.getString("autor"));
                li.setEditora(result.getString("editora"));
                livros.add(li);
            }

        } catch(SQLException e) {
            e.printStackTrace();
        }
        return livros;
}

BookList.jsp:

    <tr>
    <th>Titulo</th>
    <th>Páginas</th>
    <th>Autor</th>
    <th>Editora</th>
    <th>Editar</th>
    <th>Deletar</th>
</tr>
</thead>
<tbody>
<c:forEach var="li" items="$(livros)">
        <tr>
            <td><c:out value="$(li.titulo)" /></td>
            <td><c:out value="$(li.paginas)"/></td>
            <td><c:out value="$(li.autor)"/></td>
            <td><c:out value="$(li.editora)"/></td>
            <td><a href="Servlet?action=editar&id" >Editar</a></td>
            <td><a href="Servlet?action=deletar&id" >Deletar</a></td>
        </tr>
</c:forEach>
</tbody>

Note: I use the driver jstl1.2

What could be wrong with my code?

    
asked by anonymous 21.02.2018 / 19:21

1 answer

0
<c:forEach var="li" items="${livros}">
        <tr>
            <td><c:out value="${li.titulo}" /></td>
            <td><c:out value="${li.paginas}"/></td>
            <td><c:out value="${li.autor}"/></td>
            <td><c:out value="${li.editora}"/></td>
            <td><a href="Servlet?action=editar&id" >Editar</a></td>
            <td><a href="Servlet?action=deletar&id" >Deletar</a></td>
        </tr>
</c:forEach>
    
21.02.2018 / 19:41