2011-01-07 35 views
1

我有一組下拉控件,我想用自定義標籤庫進行渲染。以下是標記庫的代碼:窗體:在春天選擇項目問題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}" WHI ch是我想要顯示的列表,它工作正常,沒有任何問題,並綁定到表單提交所需的變量。

但我不想在標籤庫中硬編碼任何變量。 任何建議???

回答

1

有了以下變化問題已經一去不復返了

Contact.jsp

<tag:conditionalListControl path="model.selectedQualification" 
     readOnly="false" label="name" value="id" 
     listItems="${model.qualificationList}" className="simple" /> 

conditionalListControl.tag

<%@ attribute name="listItems" required="true" type="java.util.List" %> 
+0

感謝的人本! – 2013-06-07 09:36:04