自定义拦截器public class EstimateInterceptor extends AbstractInterceptor 如果继承的是AbstractInterceptor 不会拦截xml中设置的includeMethods或excludeMethods
struts2MethodFilterInterceptor类,该类是AbstractInerceptor的子类,可以实现对Action方法的拦截.实现MethodFilterInterceptor才能使用方法拦截
MethodFilterInterceptor中有两个方法
setExcludeMethods:排除需要过滤的方法
setIncludeMethods:设置需要过滤的方法
如果一个方法同时在excludeMethods和includeMethods中出现,则会被拦截
Struts2中提供了一个MethodFilterInterceptor的类,开发者自定义的拦截器只需要继承该类就可以使用这个方法过滤的功能,来拦截Action中特定的方法!
MethodFilterInterceptor类是AbstractInterceptor拦截器的子类,实现了Interceptor和Serializable接口
MethodFilerInterceptor实现方法过滤中用到的两个参数
execludeMethods:该参数指定拦截器拒绝拦截的方法列表,多个方法用“,”隔开,指定了这个参数,拦截器不会拦截指定列表中的方法 |
includeMethods:该参数指定拦截器需要拦截的方法列表,如果指定了参数,则指定的Action在执行前会被拦截 |
主要方法:
①protected
②String interceptor(ActionInvocation invocation):继承自AbstractInterceptor类,方法不需要强制重写
③void setExcludeMethods(String excludeMethods):设置拦截器黑名单,参数为Action一方法名。拦截器不拦截该方法
④void setIncludeMethods(String includeMethods):设置拦截器白名单,参数为Action一方法名。拦截器会拦截该方法
⑤Set
⑥Set