Method parameters

In the preceding code, the fibonacciSeries request method did not accept any arguments. This is because we did not expect any input. In case we foresee any input parameters, they can be bound with the following annotations:

  • @PathVariable: This annotation is used to access values for URI template variables. These templates are automatically converted into an appropriate type. If no matching type is found, a TypeMismatchException is raised:
@GetMapping("/contact/{deptId}/employee/{empId}")public Employee findEmployee(@PathVariable Long deptId, @PathVariable Long empId) {// Find the employee.}
  • @RequestParam: The annotation is used to determine values passed as query parameters. Here, data type conversion is also performed ...

Get Hands-On Reactive Programming with Reactor now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.