`
红袖添香夜半读
  • 浏览: 16771 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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内对象映射传递。
暂时未找到解决方案。
参考链接:
http://topic.csdn.net/u/20090206/12/ec2c23b6-b6d9-43e8-b176-3dc770f817fb.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics