对不起我的英语不好。我想@ManagedProperty
为 class设置TaskBO
,但它不起作用。TaskMB
班级:
@ManagedBean(name="taskMB")
@RequestScoped
public class TaskMB implements Serializable {
@ManagedProperty(value="#{TaskBO}")
public TaskBO taskBO;
public TaskBO getTaskBO() {
return this.taskBO;
}
public void setTaskBO(TaskBO taskBO){
this.taskBO = taskBO;
}
//...
}
它打印错误:
javax.servlet.ServletException: Unable to set property taskBO for managed bean taskMB
javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert com.otv.model.bo.TaskBO@6c80b8 of type class $Proxy135 to class com.otv.model.bo.TaskBO
但是如果我添加 interface ITaskBO
,它是有效的:
@ManagedProperty(value="#{TaskBO}")
public ITaskBO taskBO;
public ITaskBO getTaskBO() {
return this.taskBO;
}
public void setTaskBO(ITaskBO taskBO){
this.taskBO = taskBO;
}
为什么不@ManagedProperty
与班级合作TaskBO
?