0

I want a single API in a class to be accessible from 2 different paths.

For example: An API like getUsers should be accessible from /a/b/c/getUsers and as well as from /a/b/c/Users/getUsers.

I tried to use the placeholders using | symbol but I don't want placeholders since it Users is in the path for other APIs in other class.

Can someone please provide any solution for the same using @Path annotation in Java.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Abc
  • 55
  • 3
  • 9
  • Why would you want to do that in the first place? If one form is an old variant, wouldn't path rewriting be the better alternative? – Thomas Nov 17 '17 at 09:48
  • What is the purpose of that? Why not picking 1 approach? – B001ᛦ Nov 17 '17 at 09:49
  • see https://stackoverflow.com/questions/17000193/can-we-have-more-than-one-path-annotation-for-same-rest-method – Mick Nov 17 '17 at 10:06
  • If you are using Spring then try @RequestMapping(value = {"/def", "/abc"}, method = RequestMethod.POST). This will work for both /abc and /def. – sSaroj Nov 17 '17 at 10:13

0 Answers0