在JSP页面输出显示List
JAVA代码如下:station表中有车站名和分站名,我想在JSP页面中显示station表,要求一个车站名可以对应多个分站名List<Station>stationLi...
JAVA代码如下:
station表中有车站名和分站名,我想在JSP页面中显示station表,要求一个车站名可以对应多个分站名
List<Station> stationList = this.stationManageService.findAllStations();
Map<String, List<Station>> stationMap = new HashMap<String, List<Station>>();
for (Station s : stationList) {
String sn = s.getStationName();
List<Station> curSta = stationMap.get(sn);
if (curSta == null) {
List<Station> sList = new ArrayList<Station>();
sList.add(s);
stationMap.put(sn, sList);
} else {
curSta.add(s);
}
}
List<List<Station>> rsList = new ArrayList<List<Station>>();
for (Map.Entry<String, List<Station>> me : stationMap.entrySet()) {
rsList.add(me.getValue());
} 展开
station表中有车站名和分站名,我想在JSP页面中显示station表,要求一个车站名可以对应多个分站名
List<Station> stationList = this.stationManageService.findAllStations();
Map<String, List<Station>> stationMap = new HashMap<String, List<Station>>();
for (Station s : stationList) {
String sn = s.getStationName();
List<Station> curSta = stationMap.get(sn);
if (curSta == null) {
List<Station> sList = new ArrayList<Station>();
sList.add(s);
stationMap.put(sn, sList);
} else {
curSta.add(s);
}
}
List<List<Station>> rsList = new ArrayList<List<Station>>();
for (Map.Entry<String, List<Station>> me : stationMap.entrySet()) {
rsList.add(me.getValue());
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询