需要引入org.apache.struts2.convention.annotation.Results,结合@Result使用,定义一些映射路径。定义某方法的局部映射路径,参考样例如下:
- @Namespace("/security")
- public class UserAction extends BaseAction {
- @Action(value="change",results = {@Result(name="change" ,location = "change.jsp")})
- public String method1(){
- ......
- return "changePwd";
- @Namespace("/")
- @Results({ @Result(name = BaseAction.RELOAD, location = "index.action", type = "redirect"),
- @Result(name =IndexAction.USER_LIST, location = "/security/user.action", type = "redirect")
- @Result(name =IndexAction.ERROR, location = "error.jsp")
- })
- public class IndexAction extends BaseAction {
- public static final String USER_LIST = "user";
- public static final String ERROR = "error";
- ......