Spring mvc 3 : How to get path variable in an interceptor?

后端 未结 3 983
青春惊慌失措
青春惊慌失措 2020-12-29 04:28

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 a

3条回答
  •  一生所求
    2020-12-29 05:18

    The thread linked to by Pao worked a treat for me

    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); 
    

提交回复
热议问题