Amigos, peco ajuda de voces pois tem tres dias direto que tento rodar isso e nao funciona: o que está errado?
STRUTS CONFIG
<!DOCTYPE struts-config PUBLIC “-//Apache Software Foundation//DTD Struts Configuration 1.2//EN” “http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd”>
<struts-config>
<form-beans>
<form-bean name="/empForm" type=“app.forms.EmpregadoForm”/>
</form-beans>
<global-forwards>
<forward name=“error” path="/error.jsp" redirect=“true” />
</global-forwards>
<action-mappings>
<action
name=“empForm"
path=”/Funcionario"
type=“app.actions.EditarEmpregadoAction"
scope=“request"
parameter=“metodo"
validate=“false”>
<forward name=“sucesso” path=”/Empregado.jsp”/>
<forward name=“error” path=”/error.jsp"/>
</action>
</action-mappings>
<message-resources parameter=“ApplicationResources” null=“false”/>
</struts-config>
ACTION
package app.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import app.forms.EmpregadoForm;
import br.com.gerenciaEmpregados.Empregado;
import br.com.gerenciaEmpregados.EmpregadoService;
public class EditarEmpregadoAction extends DispatchAction{
ActionForward forward;
public ActionForward editar (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws Exception{
EmpregadoForm empForm = (EmpregadoForm) form;
EmpregadoService empService = new EmpregadoService();
ActionForward forward=null;
System.out.println("entrou no action editar");
if (empForm.getId()!=null && empForm.getId()!= 0)
{
if (empService.get(empForm.getId())== null) // nao existe, cadastro
{
try
{
Empregado emp3 = new Empregado(empForm.getId(), empForm.getNome(), empForm.getIdade());
empService.salvar(emp3);
form = null; // devolvo o objeto nulo
forward =mapping.findForward("sucesso");
}
catch(Exception e)
{
forward =mapping.findForward("error");
}
}
else// Existe o cadastro, nao altero a chave, caso a estrutura de dados fosse outra
{
try
{
Empregado emp3 = empService.get(empForm.getId());
emp3.setNome(empForm.getNome());
emp3.setIdade(empForm.getIdade());
forward =mapping.findForward("sucesso");
}
catch(Exception e)
{
forward =mapping.findForward("error");
}
}
}
else
{
forward =mapping.findForward("error");
}
request.setAttribute("listaEmp",empService.listar());
return forward;
}
public ActionForward remover (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws Exception{
EmpregadoForm empForm = (EmpregadoForm) form;
Empregado emp3 = new Empregado(empForm.getId(), empForm.getNome(), empForm.getIdade());
EmpregadoService empService = new EmpregadoService();
ActionForward forward;
try
{
empService.removerEmpregado(emp3);
forward =mapping.findForward("sucesso");
}
catch(Exception e)
{
forward =mapping.findForward("erro");
}
System.out.println("Lista>>"+empService.listar());
request.setAttribute("listaEmp",empService.listar());
return forward;
}
public ActionForward listar (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws Exception{
EmpregadoService empService = new EmpregadoService();
ActionForward forward =mapping.findForward("sucesso");
request.setAttribute("listaEmp", empService.listar());
return forward;
}
}
HTML
<%@ page language=“java” %>
<%@taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
<%@ taglib uri=“http://struts.apache.org/tags-html” prefix=“html” %>
<html>
<title>Cadastro de Funcionarios</title>
<%@ page language=“java” %>
<%@taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
<%@ taglib uri=“http://struts.apache.org/tags-html” prefix=“html” %>
<html>
<title>Cadastro de Funcionarios</title>
<body>
Cadastro de Funcionarios <p></p>
<html:form action=“Funcionario”>
<html:hidden property=“metodo” value=“editar”></html:hidden>
Id
<html:text property=“id” value=“2”/> </p>
Nome <html:text property=“nome” value=“4”/></p>
Idade <html:text property=“idade” value=“15”/></p>
<html:submit>editar</html:submit>
<html:reset value=“limpar” />
</html:form>
<jsp:include page=“Listar.do” flush=“true”/>
</body>
</html>
ERRO REPORTADO
org.apache.jasper.JasperException: Cannot retrieve definition for form bean: “empForm” on action: "Funcionario"
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)