findAttribute方法的執行順序


1.jsp代碼如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8" isErrorPage="true" isELIgnored="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>

//執行順序 page-request-session-application  <br>

<% request.setAttribute("name", "zs");%>

<%--<% request.getRequestDispatcher("/public/top.jsp").include(request, response); %>

<% request.getRequestDispatcher("/public/left.jsp").include(request, response); %>

--%>

username:<input type=text value="${name}"><br>

<%request.setAttribute("data", "aaaa");%>

<% String data=(String)pageContext.getAttribute("data",    pageContext.REQUEST_SCOPE);

out.write(data);%><br>

<%  String data1=(String)pageContext.findAttribute("data");%>

String data=(String)pageContext.getAttribute("data",pageContext.REQUEST_SCOPE);

<% out.write(data1);%>

</body>

</html>

2.程序運行如下:

//執行順序 page-request-session-application
username:
aaaa
String data=(String)pageContext.getAttribute("data",pageContext.REQUEST_SCOPE); aaaa


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com