I'm newbie about Spring
I cannot solve this problem although I try </form:option>
or <form:option ..../>
JSP
<form:select path="status"
id="cbo-position-status" class="editable-select">
<c:forEach items="${statusMap}" var = "stt">
<form:option value="<c:out value="${stt.id}"/>" label="<c:out value="${stt.name}"/>"/>
</c:forEach>
</form:select>
Controller
List<StatusBean> statuses = commonService.getAllStatus(6);
Map<Integer, String> status = new HashMap<Integer, String>();
status.put(statuses.get(0).getId(), statuses.get(0).getName());
model.addAttribute("statusMap", status);
You are using double quotes within double quotes :) Use single quotation within double quotations if they are nested.
Change the as follows:
<form:option value="<c:out value='${stt.id}'/>" label="<c:out value='${stt.name}'/>"/>
Let me know if this resolves.
you can direct map like below.
jsp page
<form:options items="${user}" itemLabel="tbuser_username" itemValue="tbuser_id"/>
controller
model.addObject("user", projectservice.getUsers());
I hope you are understand and improve your code.
Remove your
<c:out value='${stt.id}'/>
by
<form:option>
and try example below:
<c:forEach items="${statusMap}" var = "stt">
<core:set var="actionValueId" value="${stt.id}"/>
<core:set var="actionValueName" value="${stt.name}"/>
<form:option value="${actionValueId}" label="${actionValueName}"/>
</c:forEach>
Do not use JSP Tags inside the attributes of other JSP Tags. You can use the var
attribute instead.
<c:out value="${stt.id}" var="id"/>
<c:out value="${stt.name}" var="name"/>
<form:option value="${id}" label="${name}"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.