2

I have multiple REST controllers and would like all the url's to have "/rest" as the common url pattern.

E.g. (1) UserController: http://localhost:9000/rest/user (2) TicketController: http://localhost:9000/rest/ticket

Is there a way i can achieve this?

I tried:

@RequestMapping(value="/rest")
public abstract class BaseController { }

@RestController
@RequestMapping(value="/ticket")
public class TicketController extends BaseController{ 

@RequestMapping(method=RequestMethod.POST)
public Ticket createTicket(@RequestBody Ticket ticket){
    return ticketService.createTicket(ticket);      
}

}
Prashant
  • 151
  • 1
  • 2
  • 10
  • 1
    Have you tried to set the RequestMapping on TicketController to "ticket" instead of "/ticket" ? – Rafal G. May 04 '15 at 05:57
  • It throws an error: Request method 'POST' not supported – Prashant May 04 '15 at 06:28
  • 1
    RequestMapping on class-level in TicketController is overwriting the Mapping defined in BaseController. Only on method-level is supported and in your case /rest is added if you have only annotated methods with RequestMapping. – sven.kwiotek May 04 '15 at 11:11

0 Answers0