如何在Spring MVC Web App中为大多数请求运行通用代码? [英] How can I run common code for most requests in my Spring MVC Web App?

查看:84
本文介绍了如何在Spring MVC Web App中为大多数请求运行通用代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用Spring MVC RequestMapping映射的各种URL

I have various URLs mapped using Spring MVC RequestMapping

@RequestMapping(value = "/mystuff", method = RequestMethod.GET) 
@RequestMapping(value = "/mystuff/dsf", method = RequestMethod.GET) 
@RequestMapping(value = "/mystuff/eee", method = RequestMethod.GET) 

我想在90%的请求之前执行一些常规操作.这些跨越多个控制器.

I want to run some common action before about 90% of my requests. These are across several controllers.

有没有这样做而无需深入研究AOP?而且,如果我必须使用方面,那么有关如何执行此操作的任何指导?!

Is there anyway to do that without delving into AOP? And if I have to use aspects, any guidance on how to do this?!

谢谢!

更多信息:

这是要运行一些特定于应用程序的安全性-我们被链接到父安全性设置,我们需要读取并调用它,然后需要在我们大多数(但不是全部)调用之前访问cookie.

It is to run some app specific security - we are chained to a parent security set up, which we need to read and call into, and then need to access a cookie prior to some most of ours calls, but not all.

推荐答案

您可以使用拦截器:

http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-handlermapping

这篇关于如何在Spring MVC Web App中为大多数请求运行通用代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆