January 2018
Intermediate to advanced
414 pages
10h 29m
English
Spring allows us to define the HTTP verbs that our controller method will handle. We do this using the parameter method in our @RequestMapping.
For example, in our controller:
@RequestMapping(value = "/customer/{id}", method = arrayOf(RequestMethod.GET))fun getCustomer(@PathVariable id: Int) = customers[id]
This parameter is actually an array, it can be changed, if required, to accept more than one method. For example, as:
@RequestMapping(value = "/customer/{id}", method = arrayOf(RequestMethod.GET, RequestMethod.POST))fun getCustomer(@PathVariable id: Int) = customers[id]
With this change, we set that we will accept either HTTP GET or HTTP POST in this method, however, we recommend you keep one method per function in ...
Read now
Unlock full access