org.apache.struts2.convention.annotation

## Annotation Type Result

-     @Retention(value=RUNTIME)
       @Target(value=TYPE)
      public @interface Result

  This annotation is used to specify non-convention based results for the Struts convention handling. This annotation is added to a class and can be used to specify the result location for a specific result code from an action method. Furthermore, this can also be used to handle results only for specific action methods within an action class (if there are multiple).

  When this annotation is used on an action class, it generates results that are applicable to all of the actions URLs defined in the class. These are considered global results for that class. Here is an example of a global result:

        @Result(name="fail", location="failed.jsp")
       public class MyAction {
       }

  This annotation can also be used inside an `Action` annotation on specific methods. This usage will define results for that specific action URL. Here is an example of an action URL specific result:

        @Action(results={@Result(name="success", location="/", type="redirect")})
       public String execute() {
       }

- - ### Optional Element Summary

    Optional Elements
    Modifier and Type | Optional Element and Description
    --- | ---
    `String` | `location`
    `String[]` | `name`
    `String[]` | `params`
    `String` | `type`

- - ### Element Detail

    - #### name

          public abstract String[] name

      Returns:
        The name of the result mapping. This is the value that is returned from the action method and is used to associate a location with a return value.
      Default:
        "success"

  - - #### location

          public abstract String location

      Returns:
        The location of the result within the web application or anywhere on disk. This location can be relative if the type of this result is one of the pre-defined relative result types (these default to dispatcher, velocity and freemarker). Or this location can be absolute relative to the root of the web application or the classpath (since velocity and freemarker templates can be loaded via the classpath).
      Default:
        ""

  - - #### type

          public abstract String type

      Returns:
        The type of the result. This is usually setup in the struts.xml or struts-plugin.xml and is a simple name that is mapped to a result Class.
      Default:
        ""

  - - #### params

          public abstract String[] params

      Returns:
        The parameters passed to the result. This is a list of strings that form a name/value pair chain since creating a Map for annotations is not possible. An example would be: `{"key", "value", "key2", "value2"}`.
      Default:
        {}

Copyright © 2000–2024 Apache Software Foundation. All rights reserved.