form:spring mvc portlet中的选择项目问题
我有一组下拉控件,我想用自定义标签库来渲染它们。以下是标签库的代码:
<spring:bind path="${path}">
<c:choose>
<c:when test="${readOnly}">
<span class="readOnly">${status.value}</span>
</c:when>
<c:otherwise>
<form:select path="${path }" itemLabel="${label }" itemValue="${value }" items="${itemList}">
</form:select>
</c:otherwise>
</c:choose>
这是我在 JSP 文件中编写的代码:
<tag:conditionalListControl path="model.selectedCountry"
readOnly="false" label="name" value="id"
listItems="model.countryList" className="simple" />
执行后,配对返回以下错误:
[jsp:165] javax.servlet.jsp.JspException: Type [java.lang.String] is not valid for option items
但是如果我将 items="${itemList}"
更改为 items="$ {model.countryList}"
这是我想要显示的列表,它工作正常,没有任何问题,并且还绑定到表单提交时所需的变量。
但我不想对标签库中的任何变量进行硬编码。 有什么建议吗???
I have a set of drop-down control which I want to render with my custom tag library. The following is the code of the tag lib:
<spring:bind path="${path}">
<c:choose>
<c:when test="${readOnly}">
<span class="readOnly">${status.value}</span>
</c:when>
<c:otherwise>
<form:select path="${path }" itemLabel="${label }" itemValue="${value }" items="${itemList}">
</form:select>
</c:otherwise>
</c:choose>
And this is the code I have written in the JSP file:
<tag:conditionalListControl path="model.selectedCountry"
readOnly="false" label="name" value="id"
listItems="model.countryList" className="simple" />
Upon execution the paring returns the following error:
[jsp:165] javax.servlet.jsp.JspException: Type [java.lang.String] is not valid for option items
But if i change the items="${itemList}"
to items="${model.countryList}"
which is the list I want to display, it works fine without any problem and also bind to required variables on form submit.
But i don't want to hard code any variables in the tag lib.
Any suggestions???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过以下更改,问题消失了
Contact.jsp
conditionalListControl.tag
With following changes the problem is gone
Contact.jsp
conditionalListControl.tag