2

我有多个 REST 控制器,并希望所有 url 都将“/rest”作为通用 url 模式。

例如 (1) UserController: http://localhost:9000/rest/user (2) TicketController: http://localhost:9000/rest/ticket

有没有办法我可以做到这一点?

我试过了:

@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);      
}

}
4

0 回答 0