Estou emperrado no assunto struts nada dá certo:
A classe
package br.com.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import br.com.Contato;
import br.com.ContatoDAO;
public class ListaContatosAction extends Action{
public ActionForward execute (ActionMapping map, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//pesquisa no banco de dados a lista completa
List<Contato> lista = new ContatoDAO().getLista();
request.setAttribute("contatos", lista);
//ok ......para onde ir agora
return map.findForward("lista");
}
}
o xml struts-config
<?xml version="1.0" encoding="ISO-8859-1"?>a pagina lista.jsp
<%@ page language=“java” contentType=“text/html; charset=ISO-8859-1”
pageEncoding=“ISO-8859-1”%>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c” %>
Insert title here<c:forEach var=“contato” items="${contatos}">
${contato.id} - ${contato.nome}
</c:forEach>
web xml
<?xml version="1.0" encoding="UTF-8"?> testeDeStruts org.apache.struts.action.ActionServlet 1 testeDeStruts *.do<welcome-file>teste.jsp</welcome-file>
Resultado
teste url http://localhost:8080/struts/listaContatos.do
HTTP Status 404 - Servlet testeDeStruts is not available
type Status report
message Servlet testeDeStruts is not available
description The requested resource (Servlet testeDeStruts is not available) is not available.
Apache Tomcat/6.0.20
gente to dois dias tentando…