dao层
//查询所有的信息
public List<Stock> getAll() {
String hql = "FROM Stock s LEFT OUTER JOIN FETCH s.people";
return getSession().createQuery(hql).list();
}
service层
public List<Stock> getAll() {
return stockDao.getAll();
}
action
@SuppressWarnings("serial")
@Controller
public class StockAction extends ActionSupport implements RequestAware,ModelDriven<Stock>,Preparable{
@Resource
public IStockService stockService;
private Stock model;//声明一个stock
public Stock getModel(){
return model;
}
//得到一个请求域
Map<String, Object> request;
public void setRequest(Map<String, Object> arg0) {
this.request = arg0;
}
//查询
public String find(){
request.put("stock", stockService.getAll());
return "findAll";
}