사용자 요청이 Action에 도달하기 전에 가로 채 Action 실행 전 후에 다른 실행 코드를 넣을 수 있는 객체
controller에
<action name="hello" class="struts.hello.HelloAction">
<result name="success">/1013/hello.jsp</result>
</action>
action result 사이에
<interceptor-ref name="params" />
<interceptor-ref name="workflw" />생략 되어 있어서 안써도 됨(이미 정의 되어 있음)
직접 만든 인터셉트를 사용할 때는 인터셉터를 모두 넣어 주어야 한다(생략된 인터셉터는 동작 안함) 액션마다 해주어야 함
public String intercept(ActionInvocation arg0) throws Exception{
System.out.println("전 인터셉터");
String str = arg0.invoke();
// 목적지 Action의 execute 메서드 호출
//invoke 기준으로 전 인터셉터 후 인터셉터 나눠짐
System.out.println("후 인터셉터");
return str;
}
<interceptors>
<interceptor name="test" class="struts.test.TestInterceptor"></interceptor>
</interceptors>
인터셉터는 패키지 바로 밑에 있어야 하고 action위에 있어야 됨
'jsp2.0' 카테고리의 다른 글
| 2014-10-15 checkbox (0) | 2014.10.15 |
|---|---|
| 2014-10-15 인터셉터 (0) | 2014.10.15 |
| 2014-10-13 Struts2 (0) | 2014.10.13 |
| 2014-10-08 (0) | 2014.10.08 |
| 2014-10-07 (0) | 2014.10.07 |


