J'ai écrit un contrôleur Spring dans lequel je voulais utiliser une seule URL pour toutes les méthodes. Même si j'utilise des signatures de méthodes différentes int, string, object Je reçois une erreur.
@RequestMapping(value="problemAPI/ticket", method = RequestMethod.GET )
public @ResponseBody String getTicketData(@RequestParam("customerId") int customerId) {
return "customer Id: "+customerId+" has active Ticket:1010101";
}
@RequestMapping(value="problemAPI/ticket", method = RequestMethod.GET )
public @ResponseBody String getTicketStatusByCustname(@RequestParam("customerName") String customerName) {
return "Mr." + customerName + " Your Ticket is Work in Progress";
}
@RequestMapping(value="problemAPI/ticket", method = RequestMethod.POST )
public @ResponseBody String saveTicket(@RequestBody TicketBean bean) {
return "Mr." + bean.getCustomerName() + " Ticket" + bean.getTicketNo() + " has been submitted successfuly";
}
Erreur :
java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'problemTicketController' bean method
public String com.nm.controller.webservice.ticket.problem.ProblemTicketController.getTicketData(int)
to {[/problemAPI/ticket],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'problemTicketController' bean method
public java.lang.String com.nm.controller.webservice.ticket.problem.ProblemTicketController.getTicketByCustname(int) mapped.