Optional @Pathvariable in REST controller spring 4
I'm writing a Rest Service (HTTP Get endpoint), where in the below uri does the following http://localhost:8080/customers/{customer_id} fetch the details for the customer_id passed in the uri if the customer_id is not passed ( http://localhost:8080/customers ), fetch all the customers details. Code: @RequestMapping(method = RequestMethod.GET, value = "customers/{customer_id}") public List<Customer> getCustomers( @PathVariable(name = "customer_id", required = false) final String customerId) { LOGGER.debug("customer_id {} received for getCustomers request", customerId); } However, with the above