天天看點

(筆記)JSP中pageContext 與 pageContext.Application_Scope

[color=red](1)Application_1.jsp[/color]

<body>

<% String str="hello String";

pageContext.setAttribute("string_1",str);

String str1 = (String) pageContext.findAttribute("string_1");

out.println(str1);%>

</body>

[color=red](2)Application_2.jsp[/color]

<body>

<%String strr=(String)pageContext.getAttribute("string_1",[color=red]pageContext.APPLICATION_SCOPE[/color]);

out.println("get application property:" + strr); %>

</body>

[color=red](3)Application_3.jsp[/color]

<body>

<%String str=(String)pageContext.getAttribute("string_1");

out.println(str);%>

</body>

三段代碼對比 你會發現差別 哈哈!!!!

(java還是得多打多敲 哎 :cry: 我不太喜歡 但是一敲了 就想很多 :( 做起來就慢 I am junior, But I want to be Superman...)