SPRINGMVC annotation Development-SPRINGMVC parameter binding-wrapper type Pojo parameter binding

Source: Internet
Author: User
Tags wrapper

Parameter bindings for wrapper types

Requirements: Commodity search conditions. In the method of commodity query, the article realizes the incoming of the commodity query condition.

Implementation method

The first method: Add the HttpServletRequest request parameter to the formal parameter. Accept query condition parameters through request.

Second method: Let the Pojo of the wrapper type accept the query condition parameter in the formal parameter

Analysis: Features of page-pass parameters:

Complexity, diversity, conditions include: User account, product number, order information ....

If you place user accounts, product numbers, order information, etc. in simple Pojo (attributes are simple types)

In Pojo class properties are more, more chaotic. It is recommended to use the wrapper class Pojo. Packaging class Pojo class in the genus

Sex is the user, goods, orders, such as simple pojo.

Page pass and controller method parameter definitions

Note: The Itemscustom is consistent with the properties in the wrapper Pojo.

The package type can also be used to modify the product information, if the product modification parameters use HttpServletRequest request type of formal parameters, not conducive to the extension of the function. For example, if the product modification interface has both a product name and a customer name, and the product name and customer Name attribute names are the same, if you use the request type parameter, you cannot distinguish between the name of the product or the name of the customer. The packing Pojo should be used.

Learning qq:2460425648

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.