Springmvc parameter binding and springmvc binding

Source: Internet
Author: User

Springmvc parameter binding and springmvc binding
Bind the parameter in Annotation development: Convert the key/value string from the request to the form parameter by converting the key/value string, and pass the converted result to the form parameter. Springmvc supports parameter binding:1. Default supported types: HttpServletRequest, HttpServletResponse, HttpSession, Model/ModelMap 2. Simple data type, integer, string, and dateAs long as the parameter name and Parameter Name of the request are consistent, automatic binding is successful. If the parameter name and Parameter Name of the request are inconsistent, you can use @ RequestParam (specify the parameter name of the request ), add to the front of the Parameter3. pojo typeAs long as the request parameter name is consistent with the attribute name in pojo, the request parameter is automatically set to the attribute in pojo. Note: The parameters have both the pojo type and simple type. Parameter binding does not affect custom parameter binding: date type binding custom 4. Bind The packaging type pojo ParameterAnalysis: Page parameters are complex and diverse. The conditions include user account, product number, and order information... If you place all these attributes in a simple pojo (the attribute is a simple type), there are many and messy pojo class attributes. We recommend that you use the packaging type pojo. The attribute in pojo is pojo. Controller: directly using pojo to receive ItemsQueryVO is a packaged pojojsp.5. Set Type parameter binding 1. Simple type set parameter bindingControllerjsp, a collection parameter that uses arrays as form parameters to receive requests2. pojo type set parameter bindingYou can use both arrays and lists. list is usually used. (When you need to submit data in batches, bind the submitted data to list <pojo>.) Note: This pojo type set parameter is bound, you must use a list or array as an attribute in a packaging class, and then use this packaging class object as a form parameter to receive request parameters. Wrap the pojo class ItemsQueryVo and put the object that needs to be loaded with the itemsCustom set into the packaging class. Controllerjsp

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.