Struts 2 could not find result for success returned from action

I am not a native speaker of English, so I apologize if I made some kind of idiomatic mistake. I am brand new to Struts2. I developed a web project containing 3 JSP pages, a deployment descriptor (web.xml), a strut file configuration (struts.xml) with 2 actions configured inside (an action index with a name and an action named welcome) and 1 class that implements the action logic for the welcome action. When I try to execute the index action, it works fine, but if I call the welcome action in the URL (welcome.action), I get the following error:

Struts Problem Report
Struts has detected an unhandled exception:
Messages:   
No result defined for action actions.WelcomeAction and result success
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
...

Now I give you more information about the project and the environment:

Development environment

-

  • Java EE: 7
  • Struts2 : 2.3.15

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</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.jsp</welcome-file>
  </welcome-file-list>
</web-app>

struts.xml

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
  <constant name="struts.devMode" value="true" />
  <constant name="struts.configuration.xml.reload" value="true" />

  <!-- Configuration for the default package. -->
  <package name="default" extends="struts-default">
    <action name="index">
       <result>/WelcomeFromIndexAction.jsp</result>
    </action>
    <action name="welcome" class="actions.WelcomeAction">
       <result name="success">/WelcomeFromWelcomeAction.jsp</result>
    </action>
  </package>
</struts>

actions.WelcomeAction.java

package actions;
import com.opensymphony.xwork2.ActionSupport;

public class WelcomeAction extends ActionSupport{

  @Override
  public String execute(){
    System.out.println("Inside of execute method in WelcomeAction.");
    System.out.println("Result: " + SUCCESS);
    return SUCCESS;
  }
}

index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Index JSP</title>
  </head>
  <body>
      <h1>Welcome to index.jsp!</h1>
  </body>
</html>

WelcomeFromIndexAction.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Index Action</title>
  </head>
  <body>
      <h1>Welcome From Index Action</h1>
      <br />
      <h3>Current Page: WelcomeFromIndexAction.jsp</h3>
  </body>
</html>

WelcomeFromWelcomeAction.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Welcome Action</title>
  </head>
  <body>
      <h1>Welcome From Welcome Action</h1>
      <br />
      <h3>Current Page: WelcomeFromWelcomeAction.jsp</h3>
  </body>
</html>

, :

  • URL- JSP
  • , :/index.action /index → WelcomeFromIndexAction.jsp

:

  • , :/welcome.action /welcome → - Struts, .

, GlassFish Server, Debian , Tomcat 7 . - " " NetBeans. WAR , Tomcat 7, . VM Debian (Tomcat 7), GlassFish 4.0

WelcomeAction.java, println . , , Struts , , Struts2 , . , Struts2 , .

(FilterDispatcher/StrutsPrepareAndExecuteFilter). ​​ . struts.xml , ( ), . . struts.xml , .

, , , - . .

. Stackoverflow , . , Dropbox. https://dl.dropboxusercontent.com/u/101502868/NetBeans%20Struts2%20Error.png , execute, Struts.

Thank .

+4
2

- Maven , . , .

- Struts 2 Maven ( ): http://struts.apache.org/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html

Maven OS X, , , , :

Maven ( Maven 3.3.3 -Maven-3.3.3-bin.tar.gz.): http://maven.apache.org/download.cgi ( , /Users/YourUser/Downloads/ ). maven. ( :/Users/YourUser/Downloads/apache-maven-3.3.3/) maven , :

mv ~/Downloads/apache-maven-3.3.3/~/

.bash_profile, (~/.bash_profile). , vi commando, :

vi ~/.bash_profile

i,

, :

export JAVA_HOME = $(/usr/libexec/java_home)

export MAVEN = $HOME/apache-maven-3.3.3/bin

. , Maven . , , Maven :

mvn -version

Maven, Java OS X, , Maven .

0

struts.xml action editUser, dirctly perticuler

<action method="editUser" name="editUser" class="com.action.EditUserAction">
                        <result name="true">/jsp/editUser.jsp</result>
                        <result name="false">jsp/index.jsp</result>
</action>

,

class EditUserAction extendes ActionSupport{
                    public String editUser(){
                    String status = "false";
                        /**
                            do your buisness logic
                        */      
                    return status;  
                    }
                }

, ,

+1

All Articles