拦截器
基本配置
struts.xml中
name:自定义拦截器的名称
class:拦截器所在的类
<interceptor name="myInterceptor" class="com.ben.interceptor.MyInterceptor"></interceptor>
<action name="" class="">
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="myInterceptor"></interceptor-ref>
</action>
MyInterceptor.java
实现Interceptor接口,重写方法
package com.ben.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class MyInterceptor implements Interceptor{
@Override
public String intercept(ActionInvocation arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void init() {
// TODO Auto-generated method stub
}
}