2014-12-13 2 views
0

해시 맵을 표시하고 싶지만 키를 사용하고 전체 로트 대신 값 하나당 하나씩 표시하고 싶습니까? heres는 내가 무슨 뜻인지 :foreach를 사용하여 hashmap 데이터를 하나씩 표시하고 싶습니다.

    String getDescription = rs.getString("description"); 
        int level = rs.getInt("level"); 
        Timestamp startDate = rs.getTimestamp("startDateTime"); 
        Timestamp endDate = rs.getTimestamp("endDateTime"); 
        String LessonId = rs.getString("lessonid"); 
        this.less = new Lesson(getDescription, startDate, endDate, level, LessonId); 

        putDescriptions.add(less.description); 
        putStartTime.add(less.startTime); 
        endTime.add(less.endTime); 
        List list = Arrays.asList(less.date.split("2010")); 
        for (int i = 0; i < list.size(); i++) { 
         putDates.add(list.get(i).toString()); 
         Level.add(less.level); 
         LessonID.add(less.ID); 
         this.lessons.put("description", putDescriptions); 
         this.lessons.put("StartDate", putDates); 
         this.lessons.put("StartTime", putStartTime); 
         this.lessons.put("EndTime", endTime); 
         this.lessons.put("Level", Level); 
         this.lessons.put("LessonID", LessonID); 

// 위의 콩 코드가

JSTL :

 <c:forEach var="temp" items="${sessionScope.AvailableLessons['description']}"> 
        <tbody> 
         <tr> 
          <form action="" method="POST"> 
           <td> 
            <c:out value="${temp}"/> 
+0

당신은 내가 네 그게 바로 –

+0

당'의미 행 당 또는 colummns' 당'HashMap' 키를'표시 할 AkashKing 예외가 throw되었습니다. – AkashKing

답변

0

이 아래,

1) 루프 외부 있어야 충분해야하지만, table tag 안에 있습니다.

2.) for each 루프 내부에 필요에 따라 tr or td을 엽니 다.

<c:forEach var="myVar" items="${myMap}"> 
    ${myVar.key} ${myVar.value} 
</c:forEach> 
+0

이이 nullpointer를 작동하지 않았다 TD 당 값을 해시 맵 표시 할 그럴 당 또는 td' – AkashKing

+0

@AkashKing 게시판에 게시했습니다. –

+0

AkashKing

관련 문제