Spring MVC 3:如何在拦截器中获取路径变量? [英] Spring mvc 3 : How to get path variable in an interceptor?
本文介绍了Spring MVC 3:如何在拦截器中获取路径变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Spring MVC控制器中,我可以使用@PathVariable获取路径变量,以获取@RequestMapping中定义的变量的值.如何在拦截器中获取变量的值?
In Spring MVC controller, I can get path variable using @PathVariable to get the value of a variable defined in @RequestMapping. How can I get the value of the variable in an interceptor?
非常感谢!
推荐答案
与Pao链接的线程为我工作了
The thread linked to by Pao worked a treat for me
在preHandle()方法中,您可以通过运行以下代码来提取各种PathVariables
In the preHandle() method you can extract the various PathVariables by running the following code
Map pathVariables = (Map) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
这篇关于Spring MVC 3:如何在拦截器中获取路径变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文