当涉及到for循环和“id”时,它显示了零点异常。我评论所有的intgers然后代码工作正常。任何人都说我的代码有什么不对...
public List<HotelRoom> getallstudent() {
String sql = "SELECT * FROM hotelroom";
List<HotelRoom> list = new ArrayList<HotelRoom>();
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql);
int id = 0;
int numBed = 0;
long prce = 0;
int size = 0;
for (Map row : rows) {
HotelRoom hm = new HotelRoom();
id = Integer.parseInt(row.get("id").toString());
numBed = Integer.parseInt(row.get("numberOfBeds").toString());
prce = Long.parseLong(row.get("price").toString());
size = Integer.parseInt(row.get("size").toString());
hm.setId(id);
hm.setGuestHouseName(row.get("guestHouseName").toString());
hm.setImageLocation(row.get("imageLocation").toString());
hm.setLocation(row.get("location").toString());
hm.setNumberOfBeds(numBed);
hm.setPrice(prce);
hm.setRoomType(row.get("roomType").toString());
hm.setSize(size);
list.add(hm);
}
return list;
}