import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.struts2.ServletActionContext;
import javax.servlet.http.HttpSession;
/**
* 文件名称: LogInterceptor.java
* 编写人: yh.zeng
* 编写时间: 17-1-18 下午1:26
* 文件描述: todo
*/
public class LogInterceptor extends AbstractInterceptor
{
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
actionInvocation.invoke();
String actionClassName = actionInvocation.getAction().getClass().getName();
String actionMethodName = actionInvocation.getProxy().getMethod();
HttpSession session = ServletActionContext.getRequest().getSession();
return null;
}
}
Struts2 拦截器常用的获取Action、调用的方法名字、Session等
最新推荐文章于 2021-02-02 16:38:02 发布
本文介绍了一个自定义的日志拦截器LogInterceptor,该拦截器用于Struts2框架中记录Action调用的日志信息。它继承了AbstractInterceptor类,并重写了intercept方法来实现对Action方法执行前后的日志记录。
751

被折叠的 条评论
为什么被折叠?



