spring环绕通知无法拦截指定方法

阅读更多
我有一个自定义标签,我想在页面调用该标签时,spring能拦截标签的doStartTag方法,做一些相关操作,以下是自定义标签代码
/**
  *  
  */
package   com.hinge.bi.taglib;

/**
  *   @author  
  */

import   java.util.List;

import   javax.servlet.jsp.JspTagException;
import   javax.servlet.jsp.tagext.TagSupport;

import   com.hinge.bi.service.explorer.ResourceServiceI;
import   com.hinge.bi.service.taglib.TagLibServiceI;
import   com.hinge.bi.service.useradmin.UserServiceI;

public   class   UserExploreList   extends   TagSupport  

{
public   UserExploreList()

{
super();
}
public   int   doStartTag()   throws   JspTagException

{
System.out.println( "Hello   Sunning ");

return   EVAL_BODY_INCLUDE;

}

public   int   doEndTag()   throws   JspTagException

{

return   EVAL_PAGE;

}

}

以下是spring   的环绕通知代码
-----------------------------------------------

package   com.hinge.bi.taglib.aop;

import   javax.servlet.http.HttpServletRequest;
import   javax.servlet.http.HttpServletResponse;

import   org.aopalliance.intercept.MethodInterceptor;
import   org.aopalliance.intercept.MethodInvocation;

import   com.hinge.bi.service.explorer.ResourceServiceI;
import   com.hinge.bi.service.useradmin.UserServiceI;

public   class   PurviewInspect   implements   MethodInterceptor
{
private     UserServiceI   userService;

private     ResourceServiceI   resourceService;

public   void   setResourceService(ResourceServiceI   resourceService)
{
this.resourceService   =   resourceService;
}

public   void   setUserService(UserServiceI   userService)
{
this.userService   =   userService;
}

public   Object   invoke(MethodInvocation   invocation)   throws   Throwable
{
System.out.println( "Hello   Sunnning ");

HttpServletRequest   request   =   (HttpServletRequest)   invocation.getArguments()[2];  

HttpServletResponse   response=(HttpServletResponse)   invocation.getArguments()[3];

String   method=request.getParameter( "action ");  

if   (true)
{
response.sendRedirect( "/hingebi/control/login.jsp ");

return   null;
}

Object   result   =   invocation.proceed();   //   调用MyBuyBook中的buyBook方法,即真实操作

return   result;
}

}

以下是spring中的配置




















            
        
          
        
              
    





                     userExploreList 
        

        
                
                     explorePurviewInspectAdvisor 
                
        
       
    



但是在运行含有该标签的jsp时,总是直接就运行doStartTag方法了,spring没有起到拦截的作用。。

你可能感兴趣的:(Spring,JSP,Bean,Servlet,AOP)