实体类
JavaBean有特定的写法:
* 必须有一个无参构造
* 属性必须私有化
* 属性必须私有化
* 必须有用对应的get/set方法:
一般用来和数据库的字段做映射 ORM;
ORM:对象关系映射
* 表->类
* 字段->属性
* 行记录->对象
public class People {
private String name;
private String id;
public String getName() {
return name;
}
public String getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public void setId(String id) {
this.id = id;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", id='" + id + '\'' +
'}';
}
public People() {
}
public People(String name, String id) {
this.name = name;
this.id = id;
}
}
<jsp:useBean id="people" class="com.dui.xiang.Person" scope="page"
<%--对应People people= new People()--%>
<jsp:setProperty name="people" property="address" value="西安"
<%--name里是对象
property是属性
对应people.setaddress();
--%>
<jsp:getProperty name="people" property="address"/>