error prompting when using SPRINGMVC parameter annotation @pathvariable:
Missing URI template variable ' employeenumber ' for method parameter of type String
@RequestMapping (value = "/finduserbyemployeenumber/{employeenumber}", method = requestmethod.get) public
Responseentity<todouser> Findbynumber (@PathVariable @Valid String employeenumber) {
...
}
If the @requestmapping is represented as "Item/{id}", the ID and parameter names are the same, @PathVariable do not specify a name. If inconsistent, such as "Item/{itemid}", you need to specify the name @pathvariable ("ItemId").
So the parameters in the original code
The {employeenumber} variable name needs and @pathvariable in the @RequestMapping (value = "/finduserbyemployeenumber/{employeenumber}" @Valid Same as in String EmployeeNumber
Modified:
Method One: Parameter name consistent
@RequestMapping (value = "/finduserbyemployeenumber/{employeenumber}", method = requestmethod.get) public
Responseentity<todouser> Findbynumber (@PathVariable @Valid String employeenumber) {
...
}
Method Two: Add aliases
@RequestMapping (value = "/finduserbyemployeenumber/{employeenumber}", method = requestmethod.get) public
Responseentity<todouser> Findbynumber (@PathVariable ("EmployeeNumber") @Valid String number) {
...
}
Note that the two difference @PathVariable is to get the data on the URL. @RequestParam GET request parameters (including post form submission)
More SPRINGMVC usage details see my blog SpringMVC02 tutorial GitHub project Use SPRINGMVC Summary