我正在尝试使用rich:calendar,当日期属性selectedDate和currentDate是Date类型时,它可以工作。当我使用Calendar时,它不起作用。
当我提交一份表格时,它会报告:
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/PORTAL] threw exception [javax.el.ELException: /test.xhtml @58,36 value="#{bean.calendar.selectedDate}": Cannot convert 24.6.11 0:00 of type class java.util.Date to class java.util.Calendar] with root cause
javax.el.ELException: /test.xhtml @58,36 value="#{bean.calendar.selectedDate}": Cannot convert 24.6.11 0:00 of type class java.util.Date to class java.util.Calendar我的XHTML
<rich:calendar
mode="ajax" id="calendar"
value="#{bean.calendar.selectedDate}"
locale="#{calendarBean.locale}"
datePattern="#{calendarBean.pattern}"
required="true">
</rich:calendar>和日历bean
@ManagedBean
public class CalendarBean
{
private Calendar currentDate;
private Calendar selectedDate;
public Calendar getCurrentDate() {
return currentDate;
}
public void setCurrentDate(Calendar currentDate) {
this.currentDate = currentDate;
}
public Calendar getSelectedDate() {
return selectedDate;
}
public void setSelectedDate(Calendar selectedDate) {
this.selectedDate = selectedDate;
}我做错什么了?
发布于 2011-06-17 15:22:26
Calendar类具有一个time属性,该属性表示一个java.util.Date,包含一个吸气剂和塞特。好好利用它。
value="#{bean.calendar.selectedDate.time}" https://stackoverflow.com/questions/6387966
复制相似问题