天天看点

(笔记)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...)