Passando um id por url usando struts

0 respostas
S

Tento passar um id por url mas na RemoveContatoAction o valor chega 0, e consequentemente não consigo remove do banco.

struts-config.xml
<action path="/removeContato" name="RemoveContato" type="action.RemoveContatoAction">
			<forward name="ok" path="/listaContatos.do"/>
</action>
RemoveContatoForm
public class RemoveContatoForm extends ActionForm {

	private Contato contato = new Contato();
	
	public Contato getContato(){
		return this.contato;
	}
	
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.contato = new Contato();
	}
}
RemoveContatoAction
public class RemoveContatoAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		System.out.println("RemoveContatoAction");
		Contato contato = ((RemoveContatoForm)form).getContato();
		System.out.println("ID: " + contato.getId());
		new ContatoDAO().remove(contato);
		return mapping.findForward("ok");
	}
}
lista.jsp
<c:forEach var="contato" items="${contatos}">
		(<a href="removeContato.do?contato.id=${contato.id }">Remover</a>)
		${contato.id } - ${contato.nome } <br/>		
</c:forEach>
Criado 22 de junho de 2010
Respostas 0
Participantes 1