posts - 431,  comments - 344,  trackbacks - 0
公告
 Don't Repeat Yourself
座右铭:you can lose your money, you can spent all of it, and if you work hard you get it all back. But if you waste your time, you're never gonna get it back.
公告本博客在此声明部分文章为转摘,只做资料收集使用。


微信: szhourui
QQ:109450684
Email
lsi.zhourui@gmail.com
<2007年1月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

留言簿(15)

随笔分类(1019)

文章分类(3)

文章档案(21)

收藏夹

Link

好友博客

最新随笔

搜索

  •  

积分与排名

  • 积分 - 855802
  • 排名 - 47

最新评论

阅读排行榜

事例:
<%
String newImg="yes";
request.setAttribute("newImg",newImg);
%>
${newImg}
<c:set var="newImg1" value="${'10'}"/>
${newImg1}
<%= pageContext.getAttribute("newImg1")%>


原理:
jstl中的变量在赋值<c:set>的时候有个scope属性,它是用来设置该变量的作用域的,可以是
page
request
session
application
默认是page,同一jsp页面有效

这四个scope对应在jsp中可以通过
pageContext.getAttribute()
request.getAttribute()
session.getAttribute()
application.getAttribute()
得到值。

如下:

<c:set var="a" value="hello a" scope="request" />
<c:set var="b" value="hello b"/>

<%
out.print(request.getAttribute("a") + "<br/>");
out.print(pageContext.getAttribute("b"));
%>

同理,也可以从jsp中得到变量放入jstl的变量中。
posted on 2007-01-19 15:40 周锐 阅读(1515) 评论(0)  编辑  收藏 所属分类: Jsp

只有注册用户登录后才能发表评论。


网站导航: