2012-09-18 32 views
2

我试图使用弹簧复选框绑定课程对象的列表。以下是jsp代码。类型不匹配弹簧列表绑定

<form:hidden path="id" value="${student.id}"/> 
      <c:forEach items="${avacourses}" var="course" varStatus="status"> 
       <tr> 
        <td><form:checkbox path="courseList" value="${course}" /></td> 
        <td>${course.courseName}</td> 
       </tr> 
      </c:forEach> 

然后我得到以下绑定结果错误

Field error in object 'student' on field 'courseList': rejected value [[email protected]]; codes [typeMismatch.student.courseList,typeMismatch.courseList,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [student.courseList,courseList]; arguments []; default message [courseList]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'courseList' 

可以请你告诉我怎么解决这个问题? 谢谢。

回答

3

您可以使用spring ConversionService来解决此问题。