${expression }
等价于
<%
Useruser=(User)session.getAttribute(“user”);
Stringname=user.getName();
out.println(name);%>
2.
等价于
<%
Stringstr_count = request.getParameter(“count”);
intcount = Interger.parseInt(str_count );
count= count + 20;
out.println(count);
%>
3.${user.cooks[0]}
|
JSP页面 |
EL表达式 |
EL表达式访问 |
|
page |
pageScope |
${pageScope.user.name} |
|
request |
requestScope |
${requestScope.user.name} |
|
session |
sessionScope |
${sessionScope.user.name} |
|
application |
applicationScope |
${applicationScope.user.name} |
7.EL支持的算术运算符
|
运算符 |
说明 |
范例 |
结果 |
|
+ |
加 |
${17+5} |
22 |
|
- |
减 |
${17-5} |
12 |
|
* |
乘 |
${17*5} |
85 |
|
/ 或div |
除 |
${17/5}或${17 div 5} |
3 |
|
%或mod |
余数 |
${17%5}或${17 mod 5} |
2 |
以下哪种写法是正确的?
${param.password1}== ${param.password2}
${${param.password1}== ${param.password2}}
${param.password1== param.password2}
|
运算符 |
说明 |
范例 |
结果 |
|
== 或 eq |
等于 |
${5==5} 或 ${5 eq 5} |
True |
|
!= 或 ne |
不等于 |
${5!=5} 或 ${5ne5} |
False |
|
< 或 lt |
小于 |
${5<5} 或 ${5lt5} |
False |
|
> 或 gt |
大于 |
${5>5} 或 ${5 gt 5} |
False |
|
<= 或 le |
小于等于 |
${5<=5} 或 ${5 le 5} |
True |
|
>= 或 ge |
大于等于 |
${5>=5} 或 ${5ge5} |
True |
9.
|
运算符 |
说明 |
范例 |
结果 |
|
&& 或 and |
交集 |
${A && B} 或 ${A and B} |
True/ False |
|
||或 or |
并集 |
${A || B} 或 ${A or B} |
True/ False |
|
!或not |
非 |
${ !A } 或 ${not A} |
True/ False |
|
Empty |
判断值是否为null |
${empty param.name} |
True/ False |
|
${A ? B : C} |
条件判断 |
当A为true,执行B,否则执行C | |
|
( ) |
优先权 |
对算术和逻辑运算符的执行优先权 | |
10.JSTL
JSP文件引入:
<%@ taglib prefix="c" uri="core" %>//uri是第三个
或者
<c:outvalue="内容"escapeXml="布尔值"/>
session/application范围依次查找var指定的对象,找到就删除,如果找不到就不做任何事情。
Admin你好!
</c:if>
<c:whentest=“${condition }”>
….
</c:when>
<c:whentest=“${condition }”>
….
</c:when>
<c:otherwise>
….
</c:otherwise>
<%
List list=new ArrayList();
list.add("tom");
list.add("jacky");
list.add("kelly");
request.setAttribute("list",list);
%>
<c:forEachitems="${list}" var="u">
${u}<br>
</c:forEach>
1395

被折叠的 条评论
为什么被折叠?



