1.java类的属性:
1.1 在javaEE中,java类的属性通过getter和setter来定义
1.2 之前教的属性,即成员变量称之为字段。
1.3 操作java类属性有一个工具包:beanutils
搭建环境需要的jar包。 commons-beanutils-1.9.3.jar和commons-logging-1.2.jar
使用的方法:①BeanUtils.setProperty();为Javabean属性赋值
public void testBeanutils() throws Exception {
Object object = new Customers();
System.out.println(object);
BeanUtils.setProperty(object, "email", "666");
System.out.println(object);
}
②BeanUtils.getProperty();从Javabean取得属性值。
1.4 使用beanutils就可以在编写DAO的时候,从map中取值付给实体类时,使用BeanUtils.setProperty();方法。
public <T> T get(Class<T> clazz,String sql, Object ... args) throws Exception {
Connection connection = null;
PreparedStatement pr