我正在尝试将DAO注入托管属性.
public class UserInfoBean {
private User user;
@ManagedProperty("#{userDAO}")
private UserDAO dao;
public UserInfoBean() {
this.user = dao.getUserByEmail("test@gmail.com");
}
// Getters and setters.
}
Run Code Online (Sandbox Code Playgroud)
在创建bean之后注入DAO对象,但它null在构造函数中并因此导致NullPointerException.如何使用注入的托管属性初始化托管bean?
jsf constructor nullpointerexception managed-bean managed-property