今天在写项目的时候,做一个日志模块,记录用户在系统中做的操作。但是在AOP事务通知里面,通过.class对象.getMethod获取用户执行的方法时,传递的参数列表中带有RedirectAttributes的都会报异常java.lang.NoSuchMethodException
动态代理所代理的Controller中含有RedirectAttributes时报错java.lang.NoSuchMethodException动态代理所代理的Controller中含有RedirectAttributes时报错java.lang.NoSuchMethodException
后来通过debug,找到异常详细描述如下
动态代理所代理的Controller中含有RedirectAttributes时报错java.lang.NoSuchMethodException最后将 RedirectAttributes 改为RedirectAttributesModelMap就能正常使用了
动态代理所代理的Controller中含有RedirectAttributes时报错java.lang.NoSuchMethodExceptionRedirectAttributes是一个接口,RedirectAttributesModelMap 是 RedirectAttributes的实现类动态代理所代理的Controller中含有RedirectAttributes时报错java.lang.NoSuchMethodException
前面声明参数的时候用的是接口,接口不能被实例化,在将获取其class对象传递过去获取方法的时候会出现java.lang.NoSuchMethodException,所以需要用到其实现类来声明

如解释有错望指正,虚心向学

相关文章:

  • 2022-01-28
  • 2021-07-15
  • 2022-01-20
  • 2021-06-05
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
猜你喜欢
  • 2021-05-09
  • 2022-01-03
  • 2022-01-16
  • 2021-08-05
  • 2021-09-17
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案