在我的 Spring MVC 应用程序中,我从controllerServlet 返回了HashMap。现在我需要使用 JSTL 在我的 jsp 中打印它。请帮忙解决这个问题。我对这一切都是新手。
尝试这个,
假设我的地图是:-
Map<String, String> countryList = new HashMap<String, String>();
countryList.put("United States", "Washington DC");
countryList.put("India", "Delhi");
countryList.put("Germany", "Berlin");
countryList.put("France", "Paris");
countryList.put("Italy", "Rome");
request.setAttribute("capitalList", countryList);
所以在JSP中,
<c:forEach var="country" items="${capitalList}">
Country: ${country.key} - Capital: ${country.value}
</c:forEach>
希望这可以帮助 !
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)