我將兩個列表添加到一個Map map = new HashMap()中。我想使用JSTL從獲得在JSP頁面中值 我contriller是如何使用JSTL迭代Map <String,List> map = new HashMap <String,List>()在jsp頁面中使用JSTL
@RequestMapping("/addprogram")
public ModelAndView thematicday()
{
Map<String, List> map = new HashMap<String, List>();
try{
List<Themes> theme=dataServices.getTheme();
List<String> themeday=dataServices.getThematicDate();
map.put("theme", theme);
map.put("themeday", themeday);
}
catch(Exception e)
{
e.printStackTrace();
}
return new ModelAndView("thematicday","map",map);
}
我exctract第一個列表
<c:forEach var="events" items="${map.theme}">
<option value="${events.themeid}">${events.themename}</option>
但我不知道如何從字符串列表exctract值
daoImpl中的第二個列表
@SuppressWarnings("unchecked")
@Override
public List<String> getDate() {
List<ThematicDay> Themedate = null;
session=sessionFactory.openSession();
tx=session.beginTransaction();
Query query = session.createQuery("select a.themedate,a.thematicdayid from tableone a where a.thematicdayid in(SELECT thematicdayid FROM tabetwo GROUP BY thematicdayid HAVING COUNT(*) < 3)");
List<Object> result = (List<Object>) query.list();
List<String> strings = new ArrayList<String>();
for (Object object : result) {
strings.add(object != null ? object.toString() : null);
}
System.out.println("\n\n *&*&*&* "+strings);
for(int i=0; i<strings.size(); i++){
String stringArray = strings.get(i);
System.out.println("\n\n *&*&*&* "+stringArray);
}
tx.commit();
session.close();
return strings;
}
我們E該代碼來獲得該列表
<c:forEach var="Date" items="${map}">
<c:if test="${Date.key == 'themeday'}">
<div class="bottom-article">
<ul class="meta-post">
<li><a href="#" class="tl_1"> ${Date.value[0]} </a></li>
<li><a href="#" class="tl_2">${Date.value[1]} </a></li>
</ul>
</div>
</c:if>
</c:forEach>
但得到這樣
[Ljava.lang.Object;@762b0f
[Ljava.lang.Object;@4f983
你需要觀察'List