사용 클래스 : com.opensymphony.xwork2.ActionChainResult
두 개의 다른 액션에서 처음 액션의 프라퍼티를 다음 액션에 세팅하고 싶을때 chain 인터셉터를 이용한다
예를 들어 회원등록 액션과 로그인 액션이 있는데
회원등록 후 그 정보로 이어서 바로 로그인으로 진행되게 한다
RegisterUser.java |
public class RegisterUser implements Action {
private String userId;
private String password;
private String message;
public String execute() throws Exception {
// 비지니스 로직 생략
return SUCCESS;
}
// getter, setter 생략
}
|
LoginAction.java |
public class LoginAction implements Action {
private String userId;
private String password;
private String message;
public String execute() throws Exception {
// 비지니스 로직 생략
return SUCCESS;
}
//getter, setter 생략
}
|
struts.xml |
<package name="ex" extends="struts-default">
<action name="registerAndLogin" class="action.RegisterUser">
<interceptor-ref name="params"/>
<result name="success" type="chain">login</result>
</action>
<action name="login" class="action.LoginAction">
<interceptor-ref name="chain"/>
<interceptor-ref name="params"/>
<result name="success" type="dispatcher">/result.jsp</result>
</action>
</package>
|