0

Is is possible to delegate different @RequestMapping methods by evaluation get-query parameter?

Example: if I call localhost:8080/cars?format=csv I want to invoke the first method.

But if I call localhost:8080/cars?format=anyothervalue I'd like to invoke the second method. Is that possible in spring using @RequestParams?

@RestController
public class MyServlet {
    @RequestMapping("/cars", {format == 'csv'})
    public Response doGetCsv(@RequestParam format) {

    }

    @RequestMapping("/cars", {format == 'xml'})
    public Response doGetOthers(@RequestParam format) {

    }
}
membersound
  • 81,582
  • 193
  • 585
  • 1,120

0 Answers0