January 2018
Intermediate to advanced
414 pages
10h 29m
English
In Spring, we can get values coming into the URL using the annotation @PathVariable. Let's modify our controller to illustrate how:
package com.microservices.chapter3import org.springframework.beans.factory.annotation.Autowiredimport org.springframework.web.bind.annotation.PathVariableimport org.springframework.web.bind.annotation.RequestMappingimport org.springframework.web.bind.annotation.RequestMethodimport org.springframework.web.bind.annotation.RestControllerimport java.util.concurrent.ConcurrentHashMap@RestControllerclass CustomerController { @Autowired lateinit var customers : ConcurrentHashMap<Int, Customer> @RequestMapping(value = "/customer/{id}", method = arrayOf(RequestMethod.GET)) fun getCustomer(@PathVariable ...
Read now
Unlock full access