Map data to create JavaBean objects of any class

Source: Internet
Author: User

1. Required JAR Package:

Itcast-tools-1.4.jar http://pan.baidu.com/s/1Dbo2i

Commons-beanutils-1.8.3.jar http://pan.baidu.com/s/1Dbo2i

Commons-logging-1.1.1.jar http://pan.baidu.com/s/1c0yefK0

2. Map data Create JavaBean objects of any class T tobean (map, class<t>) : Put map Convert to of the specified type bean object. Typically used to get form data ( request.getparametermap () javabean common-beanutils map Span style= "FONT-FAMILY:CALIBRI;" >bean

Entities that require Person.java.
Key code Examples:
map<string,object> map = new hashmap<string,object> ();//Create Map
Map.put ("pid", "123");
Map.put ("PName", "Zhang San");
Map.put ("Age", "23");
The person field has PID, pname, age
Person p = Commonutils.tobean (map,person.class);//Use map data to create a JavaBean object of type "P" is a man object

Note: 1. As long as the key value is the same;


2. If there is a map and the person field is not, do not map to related fields


3. If there is a person, and none in map, the person corresponding field is null (string type, int is generally 0)

Map data to create JavaBean objects of any class

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.