Local results are configured to configure actions using the @Action property. In other words, local results are tuned where they are allowed. Using the @Action annotation, you specify a list of results properties. Here you can add @Result annotations.
There is an excerpt from Dave Newtonโs book Apache Struts 2 Web Application Development :
We can also customize the results with annotations to the Convention. We should not rely on the conceptual concept of the Convention that our result JSP files should be named. We can define the results manually using @Result and the @Results annotation if we need multiple Results. (We can use the @Results annotation only in the class, and the @Action and @Actions are available at the method level. We can define several results at the action level through the @Action annotation results property. )
Wiki definition is also correct
Global results are distributed among all actions defined in the action class. These results are defined as annotations for the class of actions. Local results apply only to the method of action that they are defined on . The following is an example of various types of result annotations:
com.example.actions.HelloWorld
package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Actions; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; @Results({ @Result(name="failure", location="fail.jsp") }) public class HelloWorld extends ActionSupport { @Action(value="/different/url", results={@Result(name="success", location="http://struts.apache.org", type="redirect")} ) public String execute() { return SUCCESS; } @Action("/another/url") public String doSomething() { return SUCCESS; } }
source share