E ai pessoal blz, estou com um problema aqui, estou ainda aprendendo a lidar com o Struts e estou com o seguinte problema.
Vou colocar o código do meu projeto abaixo:
funcionarioAction.java
package org.fun.action;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.actions.DispatchAction;
import org.fun.form.funcionarioForm;
public final class funcionarioAction extends DispatchAction {
public ActionForward cadastrar(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try{
return (mapping.findForward("cadastrar"));
}
catch(Exception e){
return (mapping.findForward("erro"));
}
}
public ActionForward pesquisar(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try{
return (mapping.findForward("pesquisar"));
}
catch(Exception e){
return (mapping.findForward("erro"));
}
}
public ActionForward editar(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try{
return (mapping.findForward("editar"));
}
catch(Exception e){
return (mapping.findForward("erro"));
}
}
public ActionForward excluir(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try{
return (mapping.findForward("excluir"));
}
catch(Exception e){
return (mapping.findForward("erro"));
}
}
}
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- ======================================== Form Bean Definitions -->
<form-beans>
<form-bean name="funcionarioForm" type="org.fun.form.funcionarioForm" />
</form-beans>
<!-- =================================== Global Forward Definitions -->
<global-forwards>
</global-forwards>
<!-- =================================== Action Mapping Definitions -->
<action-mappings>
<!-- Default "Welcome" action -->
<!-- Forwards to Welcome.jsp -->
<action path="/Welcome" type="org.apache.struts.actions.ForwardAction" parameter="/pages/Welcome.jsp" />
<action
path="/funcionario"
type="org.fun.action.funcionarioAction"
name="funcionarioForm"
input="funcionarioForm"
scope="request"
parameter="id"
validate="true"
>
<forward name="cadastrar" path="/pages/funcionario/cadastrar.jsp"/>
<forward name="pesquisar" path="/pages/funcionario/pesquisar.jsp"/>
<forward name="editar" path="/pages/funcionario/editar.jsp" />
<forward name="excluir" path="/pages/funcionario/excluir.jsp" />
</action>
</action-mappings>
<!-- ===================================== Controller Configuration -->
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />
<!-- ================================ Message Resources Definitions -->
<message-resources parameter="org.fun.MessageResources.MessageResources" />
<!-- ======================================= Plug Ins Configuration -->
<!-- ========== Tiles plugin =================== -->
<!-- -->
<!--
This plugin initialize Tiles definition factory. This later can takes some
parameters explained here after. The plugin first read parameters from web.xml, then
overload them with parameters defined here. All parameters are optional.
The plugin should be declared in each struts-config file.
- definitions-config: (optional)
Specify configuration file names. There can be several comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module aware. If true (default),
there will be one factory for each Struts module.
If false, there will be one common factory for all module. In this later case,
it is still needed to declare one plugin per module. The factory will be
initialized with parameters found in the first initialized plugin (generally the
one associated with the default module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header. (default)
false : no validation
Paths found in Tiles definitions are relative to the main context.
-->
<!-- comment following if struts1.0.x -->
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
<!-- end comment if struts1.0.x -->
<!-- ======================================= Plug Ins Configuration -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>
cadastrar.jsp
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html>
<head>
<title><bean:message key="inicio.titulo"/></title>
</head>
<body>
<h1><center><bean:message key="inicio.cadFun"/></center></h1>
<hr>
<html:errors ></html:errors>
<html:form action="funcionario" method="post" focus="codigo">
<html:hidden property="id" name="id" value="cadastrar"/>
<table height="450" width="350" border=0">
<tr>
<td><bean:message key="campo.codigo"/></td>
<td><html:text property="codigo" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.nome"/></td>
<td><html:text property="nome" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.telefone"/></td>
<td><html:text property="telefone" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.cidade"/></td>
<td><html:text property="cidade" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.estado"/></td>
<td><html:text property="estado" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.rua"/></td>
<td><html:text property="rua" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.bairro"/></td>
<td><html:text property="bairro" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.complemento"/></td>
<td><html:text property="complemento" size="30"/></td>
</tr>
<tr>
<td><bean:message key="campo.cargo"/></td>
<td><html:text property="cargo" size="30"/></td>
</tr>
<tr>
<td align="center"><html:submit ><bean:message key="botao.cadastrar"/></html:submit></td>
<td align="center"><html:reset ><bean:message key="botao.reset"/></html:reset></td>
</tr>
</table>
</html:form>
<br><a href="http://127.0.0.1:8080/Cadastro-Struts">Voltar Pagina Principal</a>
</body>
</html>
O erro eh o seguinte:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalArgumentException: Path funcionarioForm does not start with a "/" character
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1078)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1023)
org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:988)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.11 logs.
Quando eu coloco no struts-config no input="/pages/funcionario/cadastrar.jsp"
a pagina de cadastrar da certo so que as outras paginas quando eu mando executa redirecionam pra ela, pelo que andei pesquisando o input tem que ficar input="funcionarioForm"
, para que as outras paginas quando eu executar redirecionem para os lugares corretos.
Alguém pode me ajudar me explicando oq eu estou fazendo de errado
Valeu pela ajuda