不说废话,先上代码:
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”),请各位看看!感谢十分!