3

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

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

I can`t do it with regular expression, beacouse i dont know the URLs i will need to process. I can only retrieve them proggrammatically. So i need to make request mapping also programmatically.
@user2160696 you did't understood the main idea. you have to write only one functions for one type of url.
I dont have any "type of url". It can be /face/dodo, /face/dddd or even /faceee. And for all this array of URLs i got the special logic. For all other URLs i got premapped methods.
0

You need some form of common root, eg :

@RequestMapping("/face/*")

Or even just everything

@RequestMapping("/")

4 Comments

Nope, i got already premapped logic for /. I need my method to process array of URLs i retrieved from 3rd party service. They can be any (/face/ff, /face/dd or even /dodo/do). And i need all this URLs be mapped directly to my method.
@user2160696 so just face or dodo as the root ?
Гnfortunately i dont know the root url. It can be any. So the only way - is to set this mapping directly.
@user2160696 that is a bit more difficult forum.springsource.org/…
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.