@RequestParam is used to assign the specified parameter to the formal parameter in the method. The meaning is to mark the parameter name of the browser address bar.
@RequestParam has 3 names:
1. value: the name of the request parameter in the browser address bar, such as http://localhost:8080/login? name =zhangsan, which is @RequestParam(value = " name ")
If you do not write the value of value, the default parameter name is the variable name, http://localhost:8080/login? userName =zhangsan, as shown in the figure:
2. Required: Whether the parameter is a required item, true or false, when it is true, the browser request must pass in the corresponding parameter; if it is set to false, when there is no such parameter in the request, the default value It is null, and must have a value for a variable of a basic type.
3. defaultValue: the default value of the parameter. If the value is set, required=true will be invalid and will be false automatically. If the parameter is not passed, the default value will be used.
When you bring a parameter, @RequestParam(value = "username" )String username. When there are no parameters in the address bar, an error is reported