Kulwant
Kulwant

Reputation: 681

Spring Request Mapping URL's to One Controller

I have asked a recent question regarding a similar urls mapping to the same controller. In this case I had to give it 3 or 4 urls which is fine.

Spring Request Mapping Mis

The example contained the following.

@RequestMapping({"/protect", "/protekt", "/proteckt", "/protext"})

My issue now is there are 100-150 urls that weill essentially go through ONE controller. These URL's are to be contained in a database. I am looking for an elegant way to maintain this in the Request Mapping rather than putting 100 different URLS(that may change) particularly because the client I am working for doesn't want to make any changes to the back end. Is there an elegant way to do this? Thanks.

Upvotes: 0

Views: 798

Answers (1)

Dave Newton
Dave Newton

Reputation: 160271

I'd probably start by looking at ways to provide a SimpleUrlHandlerMapping subclass that grabbed its list of values from the DB. It's pretty straight-forward, keeps you from having to hook into any scanning, and keeps the configuration pretty localized to one chunk of XML (plus DB stuff).

(I think you only need to implement a HandlerMapping but it might be quicker to start from a SimpleUrlHandlerMapping--that'll be tomorrow's test hack for me.)

You don't say whether or not these URLs need to change at runtime; if they do then you'd need the ability to hook in at a deeper level to update the actual mappings--not sure how to do that off the top of my head.

Upvotes: 4

Related Questions