sys.jsp页面,这里想获取action中得到的news List
<s:iterator value="news" id="news" status="st">
<ul>
<li class="noticeList"><s:property value="#news.newsContent"/></li>
</ul>
</s:iterator>action中
public class GetNewsListAction extends ActionSupport
{
private List<News> news ;
public List<News> getNews()
{
return news;
} public void setNews(List<News> news)
{
this.news = news;
}
public String excute()
{
news = DAOFactory.getUserInfoDAOIMP().getNewsList();
ActionContext.getContext().put("news", news);
ServletActionContext.getRequest().setAttribute("news",news);
         HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("news", news);//网上有说各种方法的,这里都写着了。 return SUCCESS;
}
}action配置
<action name="GetNewsList"  class="com.sq.cn.action.GetNewsListAction">
<result name="success"  >stu/sys.jsp</result>
</action>配置什么的应该没有问题,这里s:iterator是怎么与action对应的啊 到底怎么能把得到的news List到前台jsp页面显示呢。。

解决方案 »

  1.   

    public String excute()
    {
    news = DAOFactory.getUserInfoDAOIMP().getNewsList();
    return SUCCESS;
    }
    }展示页面:
     <s:iterator id="news" value="news">
        <tr>
         <td><s:property value="newsContent"/></td>    newsContent是News的属性
        </tr>
    </s:iterator>
      

  2.   

    还是无效~我确定我的news里面是有数据的。。
      

  3.   

    还是无效~我确定我的news里面是有数据的。。
      

  4.   

    有的啊,都是用hibernate反转的。
      

  5.   

    我觉得我那个action就根本没执行,所以取不到数据。我要在载入页面的时候显示出那些数据。。
      

  6.   

    晕,你不是确定users有值吗?你debug一下或者system.out看看