如何使用 spring mvc 在 jsp 文件中显示地图对象数据

how to show map object data on jsp file using spring mvc

@ModelAttribute(value = "tempmap")
    public Map<Integer, String> getETypeMap(HttpServletRequest request)
            throws EmployeeBusinessException {
        Map<Integer, String> tempmap = employeeBS
                .fetchEmployeementType(userDetails.getTenantId(), userDetails.getLocaleId());
        return tempmap;
    }

这里我有 tempmap,即 HashMap 类型的对象,问题是我想在我的 jsp 文件中使用 SpringMVC 框架使用这个对象。

使用 JSTL forEach 循环迭代您的地图,如下所示:

 <c:forEach var="tempmap" items="${tempmap}">
   Key: ${tempmap.key}  - Value: ${tempmap.value}
 </c:forEach>

希望对您有所帮助.. 使用此 link 了解有关 jstl Enabling JavaServerPages Standard Tag Library (JSTL) in JSP

的更多详细信息