The parameter binding of SPRINGMVC is to receive the requested URL or parameter data of the form through the parameters of the processor method.
The data types supported by the default parameters are:
1.HttpServletRequest: Obtain the requested parameter data from the request object and place it on the controller's formal parameter
2.HttpServletResponse: Response data via Response object
3.HttpSession session domain data is manipulated through the session object.
The 4.MODEL/MODELMAP model is an interface that is used to set the modal data for the response. These two are similar.
@RequestMapping ("/queryitembyid.do")
Public String Queryitembyid (Model model,httpservletrequest request) {
1. Get the Product ID parameter
String id = request.getparameter ("id");
2. Check Product data
Item item = this. Itemservice.queryitembyid (Integer. parseint(id));
3. Responding to model data by using model
/**
* AddAttribute and AddObject are the same meaning
*/
Model.addattribute ("Item", item);
return "Item/itemedit"; Return the string directly to OK
}
Note: With simple Type binding parameters, it is recommended that you use a simple type of wrapper type (Integer), and that the underlying type (int) of the simple type is not recommended. The reason is that the underlying type cannot be a null value, and the exception is reported if it is not passed.
@RequestParam: Sets the parameter name of the request, matching the name of the method parameter to the property: value: Sets the parameter name of the request required: Sets whether the requested parameter must be passed. True: Must be passed;fasle: can be passed without passing. Default true. @RequestParam (value= "ItemId", required=true)
Parameter bindings for SPRINMVC