Cara…eu to fazendo a apostila da caelum acho que vc tbm esta …
Esta parte eu já consegui fazer…
Para seu controller, adeque aos seus metodos
@Path("/cd/lista")
public List<Cd> lista () {
return this.dao.getCdDao().listaTudo();
}
meu Listar.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Listando Cd</title>
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
</head>
<body>
<%@ include file="../menu.jsp" %>
<table>
<thead>
<tr>
<th>Id</th>
<th>Titulo</th>
<th>Artista</th>
<th>Genero</th>
<th>Ação</th>
</tr>
</thead>
<tbody>
<c:forEach items="${cdList}" var="cd">
<tr>
<td>${cd.id}</td>
<td>${cd.titulo}</td>
<td>${cd.artista}</td>
<td>${cd.genero}</td>
<td>
<a >editar</a>
</display:column>
<form action="/cd/${cd.id}" method="post" >
<input name='cd.id' value='${cd.id}' type='hidden'/>
<button type="submit" name="_method" value="PUT">Alterar cliente ${cd.id}</button>
</form>
</td>
<td>
<form action="/cd/${cd.id}" method="post" >
<input name='cd.id' value='${cd.id}' type='hidden'/>
<button type="submit" name="_method" value="DELETE">remover cliente ${cd.id}</button>
</form>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
Coleque todas as tags de heads, html, quando eu estava usando sem estava com erro… =)
E aproveitando se alguem souber me ajudar…
Eu tenho a classe
CdController e MusicaController
Dentro de Musica tenho que popular um select com os CDs cadastrados…
public void formulario () {
result.include("cdList", this.dao.getCdDao().listaTudo());
}
No JSP:
<select name=“<a href="http://musica.cd.id">musica.cd.id</a>”>
<c:forEach items="${cdList}" var=“cd”>
<option value="${<a href="http://cd.id">cd.id</a>}">${cd.titulo}</option>
</c:forEach>
</select>
Obs.: Se eu pegar o codigo do JSP jogar dentro da pagina de Listar do CdController funciona mais na pasta MusicaController não.
att