标签:属性绑定 user 复杂 code 指定 and add lis express
EL 表达式
<% pageContext.setAttribute("name","page"); request.setAttribute("name","request"); session.setAttribute("name","session"); application.setAttribute("name",application); %> ${name}
结果
page优先级最高
将page那行注释掉
所以优先级为:pagecontext,request,session,application
3.${}的原理:
与方法绑定,非与属性绑定
user.num解析
1.找user里面的getNum方法,然后方法里面的return的值返回
4.一个例子
<% User user = new User(1,"张三",86.5,new Address(1,"?寨")); System.out.println(user.toString()); pageContext.setAttribute("user",user); %> <table> <tr> <th>编号</th> <th>姓名</th> <th>成绩</th> <th>地址</th> </tr> <tr> <td>${user.id}</td> <td>${user.name}</td> <td>${user.score}</td> <td>${user.address}</td> </tr> </table>
5.EL执行表达式
<% request.setAttribute("num1",true); request.setAttribute("num2",false); %> <hr/> ${name1&&num2}
<% request.setAttribute("num1",true); request.setAttribute("num2",false); %> <hr/> ${name1 and num2}
<% List<String> list=new ArrayList<>(); request.setAttribute("num3",list); %> <hr/> ${empty num3}
标签:属性绑定 user 复杂 code 指定 and add lis express
原文地址:https://www.cnblogs.com/hanabi-521/p/14320051.html