add another defaultpathvariable method

This commit is contained in:
karan
2020-07-24 01:08:45 -04:00
parent 75775f3edb
commit 0c9556c66a

View File

@@ -66,6 +66,16 @@ public class PathVariableAnnotationController {
}
}
@GetMapping(value = { "/api/defaultemployeeswithoptional", "/api/defaultemployeeswithoptional/{id}" })
@ResponseBody
public String getDefaultEmployeesByIdWithOptional(@PathVariable Optional<String> id) {
if (id.isPresent()) {
return "ID: " + id.get();
} else {
return "ID: Default Employee";
}
}
@GetMapping(value = { "/api/employeeswithmap/{id}", "/api/employeeswithmap" })
@ResponseBody
public String getEmployeesByIdWithMap(@PathVariable Map<String, String> pathVarsMap) {