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

我有一个自定义标签,我想在页面调用该标签时,spring能拦截标签的doStartTag方法,做一些相关操作,以下是自定义标签代码
[code]/**
*
*/
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;

}

}[/code]
以下是spring 的环绕通知代码
-----------------------------------------------

[code]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;
}

}[/code]
以下是spring中的配置

[code]<?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>[/code]

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值