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
[code]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();
}
}
[/code]
RemoveContatoAction
[code]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");
}
}
[/code]
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>