现在我写好了一个dao层 一个action 并且action的list中也传进值了,在页面上不能将值显示出来(用的是ssh2框架写的)
我的dao:
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException,
SQLException {
String q = " from Watch w,Style s,Type t where w.styleID=s.id and w.typeID=t.id order by " + orderby + " "+ ascordesc;
Query query = s.createQuery(q);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
我的action:
public String list() {
Pages pages = new Pages();
pages.setPage(this.getPage());
pages.setPerPageNum(40); pages
.setFileName(CommUtil
.getActionMappingURLWithoutPrefix("watchInfo?ajax=shtml&action="
+ this.getAction()));
this.setPageList2(this.getWatchService().findWatchList("wdate", "asc",
pages));
return "watchList";
}
我的jsp页面:
 <s:iterator id="watchInfo" value="%{pageList2.objectList}">
      <tr>
       <td class="bgColor4"><div align="center"><s:property value="#watchInfo.wdate"/></div></td>
        <td class="bgColor4"><div align="center"><s:property value="#watchInfo.wweek"/></div></td>
        <td class="bgColor2"><div align="left"><s:property value="#watchInfo.typeName"/></div></td>
        <td class="bgColor4"><div align="center"><s:property value="#watchInfo.styleName"/></div></td>
        <td class="bgColor2"><div align="center"><s:property value="#watchInfo.lxrName"/></div></td>
        <td class="bgColor4"><div align="center"><s:property value="#watchInfo.zuName"/></div></td>
        <td class="bgColor4"><div align="center"><s:property value="#watchInfo.notes"/></div></td>
      </tr>
      </s:iterator>
表结构是这样的:
style (id,styleName)
tyle (id,typeName)watch(id,styleid,typeid,wdate)
其中style表中的id与watch表中的styleid关联
type表中的id与watch表中的typeid关联
请教高手了,为啥页面上不显示值呢?也不报错
还是我的方法有问题?谢谢!

解决方案 »

  1.   

    LZ  你先Debug 测试一下 看看传到jsp页面的list为空么?可能你在action里面查出来的list根本就是空的 估计这个可能性很大;
      

  2.   

    pagelist中已经传进值了,就是页面上不显示,也不报错的!
      

  3.   

    <s:iterator id="watchInfo" value="%{pageList2.objectList}">
    这个写错了 
    <s:iterator id="watchInfo" value="%{#pageList2.objectList}">
    或者
    <s:iterator id="watchInfo" value="#pageList2.objectList">
    试试
      

  4.   


    那应该是页面取值的问题
    你先用脚本<% request.getAttribute.......%>取了看看是否取到
      

  5.   

    先在后台测试
      然后
    在${list}测试
    如果${list}有值你迭代出了问题
    如果没有那就看是否存了值
      

  6.   

    要学会用debug去测试 看看调试的时候能不能取出值 你就可以判断是页面上的问题 还是后台程序的问题