I believe I can fly

虫虫的Blog

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  8 随笔 :: 2 文章 :: 2 评论 :: 0 Trackbacks
在使用Struts时,我们经常在Action中向request存储结果有两种方式,一种是直接使用setAttribute()方法,一种是先调用request的getsession()方法后,然后再使用setAttribute()方法。
开始由于不知道这两者的差别,我使用了后一种方式,即request.getSession().setAttribute(),但是这样在页面中使用logic:present时,如:
1          <logic:present name="Customers" scope="request">
2              <logic:iterate id="customer" name="Customers" scope="request">
3                  <tr><td>${customer.cname }</td><td>${customer.code }</td></tr>
4              </logic:iterate>
5          </logic:present>

如果定义scope为request.程序是始终都找不相应attribute的。
因为前一种方式是在request的范围内设置Attribute,而后一种方式中的getSession()是获取当前的session,这样设置Attribute当然是在session范围内设置Attribute,在前台当然是找不到相应的属性的。

QQ交流群:90623790
posted on 2009-06-29 00:13 虫虫 阅读(480) 评论(0)  编辑  收藏

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


网站导航: