Ajuda com Struts2

1 resposta
diogoprosoft

Galera estou começando a trabalhar com struts 2 atualmente trabalho com struts1 estou tendo alguns problemas gostaria da ajuda de vcs do forum.

Ao inicializar meu projeto esta dando esse erro

HTTP Status 404 - /Struts2/

--------------------------------------------------------------------------------

type Status report

message /Struts2/

description The requested resource (/Struts2/) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.16

Meu struts-xml esta assim

<struts>
    <!-- Configuration for the default package. -->
    <include file="struts-default.xml"/>
    <package name="default" extends="struts-default">
        <action name="incluirUsuario" method="incluirUsuario" class="com.struts.action.Principal">
           <result name="success" type="/usuario/usuario.jsp"/>           
        </action>
        <action name="inicio" method="inicio" class="com.struts.action.Principal">
           <result name="success" type="/usuario/usuario.jsp"/>           
        </action>
    </package>
</struts>

Meu web-xml

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        </welcome-file-list>
    </web-app>

Minha action

public class Principal extends ActionSupport{

    public String incluirUsuario(){
        
        Usuario usuario = new Usuario();        
        UsuarioPersistenciaDAO upd = new UsuarioPersistenciaDAO();
        
        upd.incluir(usuario);
        
        return "success";
    }
    
    public String inicio(){
        return "success";
    }
    
}

Meu jsp

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Struts 2</title>
    </head>
    <body>
    
    <s:form>
        
        <table align="center">
     	 
         <tr>
             <td><s:text name="Codigo"/></td>
             <td><s:textfield name="usuario.codigo" size="5"/></td>
         </tr>
        <tr>
            <td><s:text name="Nome"/></td>
            <td><s:textfield name="usuario.nome" size="30"/></td>
        </tr>
        <tr>
            <td><s:text name="Senha"/></td>
            <td><s:textfield name="usuario.senha" size="30"/></td>
        </tr>
        </table>
        <s:submit action="incluirUsuario" value="INCLUIR"/>
        
    </s:form>
    
    </body>
</html>

Agradeço a quem puder me ajudar :smiley:

1 Resposta

diogoprosoft

Funcionou o problema estava no struts-xml

<result name="success" type="/usuario/usuario.jsp"/> 

mudei para

<result name="success">/usuario/usuario.jsp</result>
Criado 16 de setembro de 2008
Ultima resposta 17 de set. de 2008
Respostas 1
Participantes 1