日期:2014-05-20  浏览次数:20828 次

struts2里action的返回应该怎么写?
public String search() throws UnsupportedEncodingException
{


Session session=HibernateSessionFactory.getSession();
Transaction transaction=session.beginTransaction();
String sql="from Goods where Name like '%"+Name+"%'";
System.out.println(sql);
Query query=session.createQuery(sql);
List goodList=query.list();
System.out.println(goodList.size());
transaction.commit();
HibernateSessionFactory.closeSession();
Map request=(Map)ActionContext.getContext().get("request");
request.put("goodList", goodList);
return ActionSupport.SUCCESS;
}
上面的不知道应该在result。jsp里面显示出查询结果。。求路过的大大们指导下

------解决方案--------------------
不用从request中取,只要类中有getGoodList方法就行,通过struts2的标签直接用goodList就能得到结果
------解决方案--------------------
探讨

引用:

不用从request中取,只要类中有getGoodList方法就行,通过struts2的标签直接用goodList就能得到结果

是这样么 <%= request.getAttribute("goodList") %> 能给说说具体情况么。