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中的配置

<?xml   version= "1.0 "?>
<!DOCTYPE   beans   PUBLIC   "-//SPRING//DTD   BEAN//EN "   "http://www.springframework.org/dtd/spring-beans.dtd ">
<beans>

<bean   id= "userExploreList "   class= "com.hinge.bi.taglib.UserExploreList ">

</bean>

<!--   advice配置-->
<bean   id= "explorePurviewInspect "   class= "com.hinge.bi.taglib.aop.PurviewInspect ">
<property   name= "userService ">
<ref   bean= "userService "   />
</property>

<property   name= "resourceService ">
<ref   bean= "resourceService "   />
</property>
</bean>

    <bean   id= "explorePurviewInspectAdvisor "   class= "org.springframework.aop.support.NameMatchMethodPointcutAdvisor ">        
        <property   name= "mappedName "   value= "doStartTag ">
        </property>  
        <property   name= "advice "   ref= "explorePurviewInspect ">
        </property>      
    </bean>

<!--   装配advisor-->
<bean   id= "theAdvisor "   class= "org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator ">

<property   name= "beanNames ">
                    <value> userExploreList </value>
        </property>

        <property   name= "interceptorNames ">
                <list>
                    <value> explorePurviewInspectAdvisor </value>
                </list>
        </property>
       
    </bean>

</beans>


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

你可能感兴趣的:(spring,AOP,bean,jsp,servlet)