为struts2中自己实现webwork2中的AroundInterceptor拦截器

简介:

package com.yanek.util;


import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public abstract class AroundInterceptor
  implements Interceptor
{
  protected transient Log log;

  public AroundInterceptor()
  {
    this.log = LogFactory.getLog(super.getClass()); }

  public void destroy() {
  }

  public void init() {
  }

  public String intercept(ActionInvocation invocation) throws Exception {
    String result = null;

    before(invocation);
    result = invocation.invoke();
    after(invocation, result);

    return result;
  }

  protected abstract void after(ActionInvocation paramActionInvocation, String paramString)
    throws Exception;

  protected abstract void before(ActionInvocation paramActionInvocation)
    throws Exception;
}

 

实现它:可以处理action执行前,执行后的拦截处理

 

目录
相关文章
|
7月前
Struts2的拦截器
Struts2的拦截器
25 0
|
Java
Struts拦截器解析
Struts拦截器解析
82 0
|
小程序 Java
Struts2【拦截器】(三)
Struts2【拦截器】
157 0
Struts2【拦截器】(三)
|
Java
Struts2【拦截器】(一)
Struts2【拦截器】
137 0
Struts2【拦截器】(一)
|
Java 关系型数据库 MySQL
Struts2【拦截器】(二)
Struts2【拦截器】
128 0
Struts2【拦截器】(二)
|
Java NoSQL Redis
Struts 拦截器
介绍 实现aop的方式用于实现action之前,之后执行一般用于事物操作.一般用于对某些未授权的页面访问的时候,进行拦截操作,拦截非法访问. 开箱即用拦截器 <!-- 拦截器 --> <interceptor-ref name="params"/> ...
1081 0
|
Java 容器 应用服务中间件
12 Struts2 拦截器
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hxdeng/article/details/81941425 拦截器 拦截器在概念上和Servlet过滤器或JDK代理类一样。
1234 0
|
SQL Java 数据库
Struts2【拦截器】就是这么简单
什么是拦截器 拦截器Interceptor.....拦截器是Struts的概念,它与过滤器是类似的...可以近似于看作是过滤器 为什么我们要使用拦截器 前面在介绍Struts的时候已经讲解过了,Struts为我们实现了很多的功能,比如数据自动封装阿..文件上传功能阿....Struts为我们提供的这些功能都是通过拦截器完成的...... 数据自动封装通过这个拦截器。
1100 0

热门文章

最新文章