AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
## 代码 ~~~ package com.like.intercept; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor; public class MyIntercept3 extends MethodFilterInterceptor { @Override protected String doIntercept(ActionInvocation actionInvocation) throws Exception { System.out.println("before"); String invoke = actionInvocation.invoke(); System.out.println("after"); return invoke; } } ~~~ ~~~ <package name="default" namespace="/" extends="struts-default"> <!--为package下面所有action申明拦截器--> <interceptors> <interceptor name="MyIntercept3" class="com.like.intercept.MyIntercept3"> <!--指定不拦截的方法--> <param name="excludeMethods">index2</param> </interceptor> </interceptors> <!--执行在访问action的时候需要执行的拦截器组--> <action name="index2" class="com.like.HelloAction" method="index2"> <!--如果没有指定方法,将会拦截action中所有的方法--> <interceptor-ref name="MyIntercept3"/> <result name="success">/index.jsp</result> </action> </package> ~~~