我有一个使用 Spring 2.5 开发的 Web 应用程序。该应用程序有许多 Controller ,包含 GET 和 POST 请求方法,这些方法用 RequestMapping 注释标记,如下所示:
@RequestMapping(method = RequestMethod.GET)
我想在每个这样的请求之前执行一些代码,而不修改现有的 Controller 。如果可能的话,我怎样才能做到这一点?
最佳答案
您想使用HandlerInterceptor
。这些“横切”你的 Controller 。看这个Spring docs for more info .
关于java - Spring Web 应用程序 : executing common code before entering RequestMapping in controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2418832/