用HQL语句查询完整的记录(全部字段信息),且在JSP中用下拉列表显示其各字段的值
注:想用下拉列表来显示(List)的对象值,必须用QHL语句来查询,用SQL语句查询出来的是数组,下来列表不能显示
在service中:
/*************************************************/
@SuppressWarnings("unchecked")
public List<HotelInfo> hotelListById(String mtid) {
// String sql = " select * FROM YC_HOTEL_INFO_T hi ";
// sql += " WHERE hi.MTID = '" + mtid + "'";
// sql += " ORDER BY hi.HID DESC";
String hql ="from HotelInfo t where t.meetingInfo.mtid='"+mtid+"' order by hid desc";
List<HotelInfo> list = null;
try{
list = hotelInfoDAO.findAllByHql(hql);
}catch (Exception e) {
e.printStackTrace();
}
return list;
}
/*************************************************/
在JSP中用下拉列表来显示对象列表(list)的各字段值:
<s:select name="guest.roomPlaned" id="guest.roomPlaned" listKey="hid" listValue="hotel" list="hlist" headerKey="no" headerValue="暂不安排" οnchange="detail()" />