我想從mysql數據庫中獲取位置名稱。我想檢索所有位置名稱並收集到ArrayList
和此列表請求setAttribute
到jsp。將String []轉換爲ArrayList
ArrayList<Bean> SupplyLocation = new ArrayList<Bean>();
try {
//...
while(rs.next()) {
Bean Location = new Bean();
String supply[] = (rs.getString("location_name")).split(",");
for(int i=0; i<supply.length; i++) {
Location.setLocation(supply);
SupplyLocation.add(Location);
}
}
}
這不會編譯... –