NullPointerException但是为什么?



我有一个class where

@Enumerated(EnumType.STRING)
private StateOfDispatchToWD stateOfDispatchToWD = StateOfDispatchToWD.NONE;

getter和setter:

public StateOfDispatchToWD getStateOfDispatchToWD() {
return stateOfDispatchToWD;
}
public void setStateOfDispatchToWD(StateOfDispatchToWD stateOfDispatchToWD) {
this.stateOfDispatchToWD = stateOfDispatchToWD;
}

和方法:

public boolean isSuccessfullySentToWD() {
return zoj.getStateOfDispatchToWD() == StateOfDispatchToWD.SUCCESSFULLY_DISPATCH;
}

并从JSF调用:

<p:outputLabel value="OK"
rendered="#{Z.isSuccessfullySentToWD()}"/>

,有时我得到:

[javax.enterprise.resource.webcontainer.jsf.lifecycle]
javax.el.ELException: //content/resources/zo.xhtml @240,92 rendered="#{Z.isSuccessfullySentToWD()}":
java.lang.NullPointerException:
javax.faces.FacesException:
javax.el.ELException: //content/resources/zo.xhtml @240,92 rendered="#{Z.isSuccessfullySentToWD()}":
java.lang.NullPointerException

但是为什么呢?恐怕我不明白。非常感谢。

可能Z的作用域是错误的,尝试将其放在会话或应用程序作用域

相关内容

  • 没有找到相关文章

最新更新