Local results are configured to the action config using @Action
property. In other words local results are configured where they allowed to. Using @Action
annotation you specify a property results
list. This is where you can add @Result
annotations.
There is a excerpt from the Dave Newton's book "Apache Struts 2 Web Application Development":
We can also configure results with Convention's annotations. We don't
have to rely on the Convention plug-in's idea of what our result JSP
files should be named. We can define results manually using the
@Result
annotation, and the @Results
annotation if we need multiple
results. (We can use the @Results
annotation only at the class
level, while the @Action
and @Actions
annotations are available at
the method level. We can define multiple results at the action level
via the @Action
annotation's results
property.)
The wiki definition also correct
Global results are shared across all actions defined within the action class. These results are defined as annotations on the action class. Local results apply only to the action method they are defined on. Here is an example of the different 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;
}
}