Struts 2 Annotation: @ResultPath
June 14, 2014
@ResultPath in struts 2 is used to change default location of results. @ResultPath annotation can be applied on class level as well as in package-info.java. It belongs to the package org.apache.struts2.convention.annotation. Default location of result is project root directory. We can change it as below
@ResultPath("/WEB-INF/user")
Action Class Without @ResultPath
In this action class @ResultPath has not been used. So default location of result is project root directory and accordingly location attribute will be assigned for the file location.@Namespace("/user") @Action("/form") @Result(name="success",location="/user/user.jsp") public class UserAction extends ActionSupport{ public String execute() { return SUCCESS; } }
Action Class Using @ResultPath
In the below action class code snippet, @ResultPath is being used. Find the differences for location attribute.@Namespace("/user") @ResultPath(value="/") @Action("/form") @Result(name="success",location="user.jsp") public class UserAction extends ActionSupport{ public String execute() { return SUCCESS; } }