user2160696
user2160696

Reputation: 709

Add RequestMapping to controller

I got a controller

@Controller
public class ModxProxyController
{
    @RequestMapping("/face/blog")
    public ModelAndView processFace()
    {...}
}

It only processes request to URL /face/blog. And i need it to process (in the same method) more URLs. But to the moment my app starts I don't know that URLs. I can retrieve them once a day from 3rd party service. So the task is - programmatically add URLs to be processed with this method (processFace).

Upvotes: 3

Views: 504

Answers (3)

Martin Frey
Martin Frey

Reputation: 10075

I am not sure if you can define requestmappings with property placeholders. If this is possible i would write a property evaluator that fetches these mappings "once a day". You could implement this lookup against a database if needed or even a property file.

Upvotes: 0

NimChimpsky
NimChimpsky

Reputation: 47280

You need some form of common root, eg :

@RequestMapping("/face/*")

Or even just everything

@RequestMapping("/")

Upvotes: 0

Dmitry Zagorulkin
Dmitry Zagorulkin

Reputation: 8548

you could use regexp in

  @RequestMapping("/face/regexp")

example:

@RequestMapping(value="/{textualPart:[a-z-]+}.{numericPart:[\\d]+}")
public String regularExpression(
  @PathVariable String textualPart,
  @PathVariable String numericPart){

    System.out.println("Textual part: " + textualPart + 
      ", numeric part: " + numericPart);
    return "someResult";
}

from http://www.byteslounge.com/tutorials/spring-mvc-requestmapping-example

Upvotes: 2

Related Questions