[英]SPRING form:option "Unterminated <form:option tag"
I'm newbie about Spring我是春天的新手
I cannot solve this problem although I try </form:option>
or <form:option ..../>
尽管我尝试了
</form:option>
或<form:option ..../>
但我无法解决这个问题
JSP 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 jsp页面
<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.不要在其他 JSP 标签的属性中使用 JSP 标签。 You can use the
var
attribute instead.您可以改用
var
属性。
<c:out value="${stt.id}" var="id"/>
<c:out value="${stt.name}" var="name"/>
<form:option value="${id}" label="${name}"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.