JavaBean
作者:互联网
JavaBean
jsp中可以使用useBean类似java对类的操作
<% People p = new People(); p.setId(1); p.setName("张三"); p.setAge(18); p.setAddress("西安"); p.getId(); p.getAge(); p.getName(); p.getAddress(); %>
而这等价
<jsp:useBean id="people" class="com.zhang.pojo.People" scope="page"/> <jsp:setProperty name="people" property="id" value="1"/> <jsp:setProperty name="people" property="name" value="张三"/> <jsp:setProperty name="people" property="age" value="18"/> <jsp:setProperty name="people" property="address" value="北京"/> <p> <span>id:</span> <jsp:getProperty name="people" property="id"/> </p> <p> <span>姓名:</span> <jsp:getProperty name="people" property="name"/> </p> <p> <span>年龄:</span> <jsp:getProperty name="people" property="age"/> </p> <p> <span>地址:</span> <jsp:getProperty name="people" property="address"/> </p>
标签:java,useBean,对类,jsp,id,JavaBean 来源: https://www.cnblogs.com/Sum-muji/p/15091625.html