struts2 的iterator标签的循环不出值(分已经用完拉,请各位援助下)

不说废话,先上代码:

public class RetakePic {
    
    private List<Goods> goodsList;
    private int speakId;
    
    public void setGoodsList(List<Goods> goodsList){
        this.goodsList = goodsList;
    }
    public List<Goods> getGoodsList(){
        return this.goodsList;
    }   
    public void setSpeakId(int speakId){
        this.speakId = speakId;
    }
    public int getSpeakId(){
        return this.speakId;
    }
    
    public List<Goods> getGoodsPic() throws Exception{
        
        Session session = HibernateSessionFactory.getSession();
        Transaction tran = session.beginTransaction();
        String sql = "from Goods as g where g.speak=" +speakId;
        Query query = session.createQuery(sql);
        goodsList = query.list();
        tran.commit();
        session.close();
        
        
        System.out.println(speakId);
        return goodsList;
    }
}

 

前台页面的输出:

<s:bean name="com.shaiyaya.business.RetakePic" id="picList">
                                    <s:param name="speakId">
                                        <s:property value="#speak.speakId"/>
                                    </s:param>
                            </s:bean>                         
                            <s:iterator value="%{#picList.getGoodsPic()}" id="pic" >
                                <s:property value="#pic.url" default="test"/>
                                                            </s:iterator>

 

 

System.out.println(speakId);在后台已经输出值了,表明方法已经执行,但是前台的<s:property value="#pic.url" default="test"/>这句什么都没有输出(包括“test”),请各位看看!感谢十分!

在方法里面先打印一下list 看是否为null或者是否没有数据。

是什么都没有 还是报错。
你试试在iterator里面随便写个字符串 看可不可以出来。

[code="java"]会用正则吧?用正则比较方便[/code]