Struts2 can not find index

0

Good morning, I'm doing a small project with the new version Struts 2.5.13 and following the guide official I can not get it started. (Error 404, can not find resource).

ACTION An action as simple as possible:

@SuppressWarnings("serial")
public class InitAction extends ActionSupport implements SessionAware{


   @Override
   public String execute()
   {
      String resultado="success";       
      System.out.println("Holaaa resul("+resultado+")");

      return resultado;
   }
}

struts.xml

<constant name="struts.devMode" value="true" />

<package name="default" extends="struts-default">        
    <action name="init" class="com.mncars.commons.actions.InitAction">
        <result name="success">/index.jsp</result>
    </action>
</package>

Web.xml

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd ">

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>


<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>   

<session-config>
    <session-timeout>120</session-timeout>
</session-config>

Index.jsp

<%@page import="java.net.URLDecoder"%>
<%
   HttpSession ses = request.getSession();
   response.sendRedirect("init");
%>
Bienvenido a la pagina!

The libraries I use are:

commons-fileupload-1.3.3.jar
commons-lang3-3.6.jar
freemarker-2.3.23.jar
javassist-3.20.0-GA.jar
log4j-api-2.8.2.jar
mybatis-3.2.2.jar
ognl-3.1.15.jar
struts2-core-2.5.13.jar

Project:

Tested URL

link

    
asked by nachfren 19.09.2017 в 17:46
source

1 answer

1

Make sure your <context-root> is defined. In JBoss and Tomcat the name of your war file becomes the "context root", example: FacturaModerno.war - > /FacturaModerno Another way to define it is using application deployment descriptor or file application.xml

<application...>
    <display-name>Factura Moderno</display-name>
    <module id="FacturaModerno">
        <web>
            <web-uri>FacturaModerno.war</web-uri>
            <context-root>/FacturaModerno</context-root>
        </web>
    </module>
...

Use the url http://localhost:8080/FacturaModerno/ to access the index.jsp

    
answered by 27.10.2017 в 17:06