<jsp:useBea id="customer" class="com.stuipid.bean.Customer" scope="session"></jsp:useBean>
<%--
//上面等价于下列操作
//1.从scope(session)中获取id(customer)属性值,赋值给class(com.stuipid.bean.Customer)类型的id(customer)变量
Customer customer = (Customer)session.getAttribute("customer");
//2.若属性为NULL,则利用反射创建一个新的对象复制给ID(customer),并以id(customer)为属性名加入到scope(session)中
if(customer == null){
customer =(Customer) Class.forName("com.stuipid.bean.Customer").newInstance();
session.setAttribute("customer", customer);
}
--%>
<jsp:setProperty property="age" value = "10" name="customer"/>
age: <jsp:getProperty property="age" name="customer"/><br>
<%--
customer.setAge(10);
<%=customer.getAge() %>
---%>
<!-- 若property 的值为*,省略value值,则自动为所有属性赋值为对应的请求参数 -->
<jsp:setProperty property="*" name="customer"/>
age: <jsp:getProperty property="age" name="customer"/><br>
Address: <jsp:getProperty property="address" name="customer"/><br>
name: <jsp:getProperty property="name" name="customer"/><br>
<jsp:useBean id="customer2" beanName ="com.stuipid.bean.Customer" type="java.lang.Object" scope="request" ></jsp:useBean>
<%--
Object customer2 = request.getAttribute("customer");
if(customer2==null){
customer2 = Class.forName("com.stuipid.bean.Customer").newInstance();
request.setAttribute("customer2",customer2 );
}
--%>