Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Rest Request 406 Not Acceptable for ".123"

I have a Spring RestController with a RequestMapping and a PathVariable:

@RequestMapping(value = "/path/{someId:.+}")
public void method(@PathVariable("someId") String someId) {
   ...
}

When calling this controller, I get a Http 406 Not Acceptable error with requests like:

- /path/id8327.123
- /path/id8327.txt

But not with:

- /path/id8327.234
- /path/id8327.bbb

Isn't that strange? It was only recently I found out that .txt also failed, so I guess it has something to do with extension mappings.

How can I work around this hidden feature?

Kind regards

like image 205
codesmith Avatar asked Nov 01 '25 15:11

codesmith


1 Answers

You can add a '/' at end of the URL, like:/path/id8327.123/.

This method can help Spring to recognize.

like image 56
Null Avatar answered Nov 03 '25 06:11

Null



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!