首页 > 编程语言 > 详细

javabean

时间:2015-06-16 16:14:14      阅读:183      评论:0      收藏:0      [点我收藏+]

创建Person类

public class Person {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        
        return super.toString();
    }

}
<body>
<%
        Person p = new Person();
        p.setName("haha");
        p.setAge(32);
        request.setAttribute("person", p);
    %>
        
    ${person.name}//第一种
    ${requestScope.person.age}//第二种

</body>

以上输出 haha 32

第一种会全域查找person这个key,第二种直接指定person的域,速度比第一种快

 

javabean

原文:http://www.cnblogs.com/sflik/p/4580781.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!