spring aop 切入aciton

问题描述:
<aop:config proxy-target-class="false">
<aop:pointcut
expression="execution(* test.service.impl.User*.sendxinxi(..))"
id="checklogin" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="checklogin" />

<aop:aspect id="aspect" ref="aspectBean">
<aop:before method="print" pointcut-ref="checklogin" />
</aop:aspect>
</aop:config>

上述代码配置切入在业务层的所有方法,代码运行正常。
如果切入Acton,例如
<aop:pointcut  expression="execution(* test.action.LoginAction.execute())" id="checklogin"/>

会出现jsp提交的username和password的值无法注入到Action中。
经过一番搜索得知原因:
在struts2的表单数据映射到action的对象过程之前,是先执行struts2内部的默认拦截链,当然也可以显式定义,例如
<interceptor-ref name ="defaultStack"/>

注意strut2的拦截器:
public String intercept(ActionInvocation actionInvocation) throws Exception 

当用自定义AOP方法拦截struts2的action时,虽然自定义的切入方法能正常运行,但截断了struts2默认拦截器ActionInvocation的传递,也就中断了表单数据向action内对象映射传递。
暂时未找到解决方案。
参考链接:
[url]http://topic.csdn.net/u/20090206/12/ec2c23b6-b6d9-43e8-b176-3dc770f817fb.html[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值