Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Annotations > Result Annotation
Added by Dave Newton, last edited by Dave Newton on Feb 02, 2007  (view change)

The @Result annotation allows the definition of Action results in the Action class rather than an XML file.

@Result Parameters

  • name - Result name; default Action.SUCCESS
  • value - Value of result (result destination)
  • type - Type of result; default NullResult. For example:
    • ServletRedirectResult
    • ServletActionRedirectResult - Equivalent to redirect-action type in XML config.
    • TilesResult
  • params

@Result – Defining a Single Sesult

Map the "success" result (explicitly named) to a Tile definition named "/home.page".

Defining a Single Result
@Result(name="success", value="/home.page", type=TilesResult.class)
public class HomeAction extends ActionSupport {
    // ...
}

@Results – Defining multiple results

Define a set of results for an Action.

Defining Multiple Results
@Results({
    @Result(name="success", value="/home.page", type=TilesResult.class),
    @Result(name="homeError", value="/homeError.page", type=tilesResult.class)
})
public class HomeAction extends ActionSupport {
    // ....
}