Exception handling and after advice

不想你离开。 提交于 2019-12-02 09:30:56

Please read the Spring AOP manual, especially the chapter about advice types. In general it is always a good idea to read a manual before using a new technology. ;-)

  • @After is always executed after a method terminates, no matter if there was an exception or not. More specialised versions only run
  • @AfterThrowing an exception or
  • @AfterReturning regularly. The latter is what you are looking for and it even gives you access to the return value if you like to log it or so.

None of these advice types will let you handle the exception, though, as I also explain here. You need to use an @Around advice for that.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!