f-angi
12/18/2015 - 12:09 PM

Renders a select in a jsp from a Map

Renders a select in a jsp from a Map

    <select id="select-province">
        <c:forEach items="${provinceMap}" var="provincia">
            <option value="${provincia.key}">${provincia.value}</option>
        </c:forEach>
    </select>
    public void handler(ActionRequest actionRequest, ActionResponse response, Model model) {

        Map<String, String> provinceMap = new LinkedHashMap<String, String>();
        provinceMap.put("VR", "Verona");
        provinceMap.put("TN", "Trento");
        provinceMap.put("BZ", "Bolzano");
        model.addAttribute("provinceMap", provinceMap);

        response.setRenderParameter("view", "view-province");
    }