码迷,mamicode.com
首页 > 编程语言 > 详细

struts2、spring调整, 报java.lang.NoSuchMethodException

时间:2014-05-09 13:41:25      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:class   java   c   int   get   cti   

  struts2、spring整合, 报java.lang.NoSuchMethodException

     用spring做为struts2的ObjectFactory,用spring来生成action,并对action的方法加上aop时,不要使Action继承于ActionSupport,否则会出现类似于以下的异常:java.lang.NoSuchMethodException: $Proxy84.executeList()
at java.lang.Class.getMethod(Class.java:1581)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:55)

我的Action类继承于ActionSupport类,没有直接实现什么接口。我用AOP把事务加在了Action里的execute打头的方法前,结果,运行时就出现了上面的找不到方法的异常,如果不让Action继承于ActionSupport类就没有了这样的问题。在调试的时候,发现spring生成的代理类里面只有一个execute方法。看来spring在生成代理类时,如果找不到被代理类直接实现的接口,就会到它的超类中去找。在这个例子中,spring就找到了ActionSupport实现的Action接口。我又试过在struts.xml里定义让struts2以接口的方式去取Action,Action实现一个自己接口,结果struts2又报另外一个错误。看来在这种情况下,只好不要让Action继承于struts2的ActionSupport类了。

struts2、spring调整, 报java.lang.NoSuchMethodException,布布扣,bubuko.com

struts2、spring调整, 报java.lang.NoSuchMethodException

标签:class   java   c   int   get   cti   

原文地址:http://www.cnblogs.com/mxyhws/p/3718274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!