jsp页面如下:
<%@page contentType="text/html; charset=gbk"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<html>
<head>
<title></title>
</head>
<%
Integer testHBM = new Integer(1);
pageContext.setAttribute("testHBM",new Integer(10)); //1
request.setAttribute("testHBM",new Integer(11)); //2
application.setAttribute("testHBM",new Integer(12)); //3
%>
<body>
<c:out value="start-----------"/><br/>
<c:if test='${testHBM == 12}'>
<c:out value="${testHBM}"/><br/>
</c:if>
<c:out value="end-------------"/>
</body>
</html>
******************************************************************
<c:if test='${testHBM == 12}'>,这个标签,如果不是写成requestScope.testHBM==12时,
会先查page范围,然后request范围,最后是application.
博客展示了一个JSP页面代码,在页面中设置了pageContext、request、application的同名Integer变量。同时提到<c:if>标签在不指定作用域时,会按page、request、application范围依次查找变量。
4922

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



