0

I need to Map a URL eg. testdata-p-12345 in my Controller, currently im trying to do it with this mapping.

@RequestMapping(value = "/**/*-p-")

And for the first variable:

...
private static final String CODE_PATH_VARIABLE_PATTERN = "{myCode:.*}";
@RequestMapping(value = CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
    public String getDetail(@PathVariable("myCode") final String myCode, final Model model,

...

When im calling the following URL the controller does not get called, does Spring support dashes inside the request mapping, how should the mapping look?

https://localhost:9002/my/test-page/to/testdata-p-40022

pr191ex
  • 88
  • 1
  • 14

2 Answers2

0

Yes, Spring supports dashes inside the request mapping. And your code works perfectly with the following call:

https://localhost:9002/my/test-page/to/testdata-p-/40022

Notice the additional slash between -p- and 40022.

If you don't specify a leading slash in your request mapping path, the default request mapping handler will do it for you!

See https://stackoverflow.com/a/12744010/7709086.

Community
  • 1
  • 1
kagmole
  • 2,005
  • 2
  • 12
  • 27
-1

you can set @RequestMapping with two or more vlue.

`    
@RequestMapping(value={"/hello","hello2"})
public Response hello(){
    return ok().put("hello", "hello world!");
}
`
code_li
  • 1
  • 1