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

我只是一个虾纸丫 提交于 2019-12-02 22:15:19

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

There is a thread in the Spring forums, where someone says, there is no "easy way", so i suppose you would have to parse the URL to get it.

Almost 1 year too late, but:

         String[] requestMappingParams = ((HandlerMethod)handler).getMethodAnnotation(RequestMapping.class).params()

         for (String value : requestMappingParams) {...

should help

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