블로그 이미지
헤이장

Notice

Recent Post

Recent Comment

Recent Trackback

calendar

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
  • total
  • today
  • yesterday
2009. 7. 27. 13:13 Web/Framework

사용 클래스 : 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>

posted by 헤이장