java反射调用set方法时如果让参数做自动类型转换5
这段时间学习java的反射机制想实现一个功能:遍历一个Map,然后利用反射机制调用BO的set方法,完成BO属性的自动注入。这样设计的初衷是解决Excel数据导入问题中的Map数据填充BO这一过程。
下面是一个BO:
Java代码
1.package com.handlewell.testOnly.persistence;
2.
3.
4.
5.import java.io.Serializable;
6.import java.util.Date;
7.
8.public class StudentBO implements Serializable{
9.
10. /**
11. *
12. */
13. private static final long serialVersionUID = 1L;
14.
15. private Long id;
16.
17. private String sname;
18.
19. private Integer age;
20.
21. private Date birthDate;
22.
23. public Long getId() {
24. return id;
25. }
26.
27. public void setId(Long id) {
28. this.id = id;
29. }
30.
31. .
32. .
33. .
34.
35.}
package com.handlewell.testOnly.persistence;
import java.io.Serializable;
import java.util.Date;
public class StudentBO implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Long id;