2

Does Spring 4 keep an internal record of the mappings that are specified with @RequestParam? I am looking for a list of these mappings.

For example, if I annotate a method with:

@RequestMapping(value = "/myname", method = RequestMethod.POST)

I would want a list with myname.

I looked around a bit and I know about the Spring MVC Router project but I am simply looking for a method call that would return the mappings. Or alternatively, a list of all the paths registered with <mvc:view-controller/> would work too.

Background:

We have a business requirement to create public areas on our web application, similar to the tumblr model where you can have myname.domain.com and access an area created by that user. However, our method is using domain.com/myname since programmatically creating the former was not simple (would need to monkey with DNS/web server config files).

We extended GenericFilterBean to do this, but I want to make sure that when searching for 'myname,' the application can ignore actual pages (or more specifically, views) on the site. We want the front-end validation to disallow existing page names.

riddle_me_this
  • 8,575
  • 10
  • 55
  • 80

1 Answers1

2

I think your question was already answered in here. This is a very good answer.

Community
  • 1
  • 1
Luke Bajada
  • 1,737
  • 14
  • 17
  • Wouldn't that return the methods? – riddle_me_this Jun 18 '15 at 23:19
  • You are right, but if you do this.handlerMapping.getHandlerMethods().keySet() I think you would get what you need. – Luke Bajada Jun 18 '15 at 23:21
  • Having an issue autowiring in Spring 3.2 - will work through it: `No qualifying bean of type... RequestMappingHandlerMapping] is defined: expected single matching bean but found 2:` Tried also just autowiring the context but no luck. – riddle_me_this Jun 19 '15 at 02:02
  • Would using `@Qualifier("")` on the field help you solve this issue? Maybe through component scanning or something else you're creating more than one of this bean. – Luke Bajada Jun 19 '15 at 07:06
  • I was able to iterate as you mentioned, but it was a little bit more than just getting the keySet: `requestMappingHandlerMapping.getHandlerMethods().keySet(); for (RequestMappingInfo info : endpoints) { for (String urlPattern : info.getPatternsCondition().getPatterns()) { ...` – riddle_me_this Feb 12 '17 at 23:20