[置頂] spring aop 切入aciton

來源:互聯網
上載者:User
問題描述:
<aop:config proxy-target-class="false"><aop:pointcutexpression="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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.