NullPoInterException,但是为什么?
我上课的地方
@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
但是为什么呢?恐怕我不明白。多谢。
I have class where
@Enumerated(EnumType.STRING)
private StateOfDispatchToWD stateOfDispatchToWD = StateOfDispatchToWD.NONE;
And getter and setter:
public StateOfDispatchToWD getStateOfDispatchToWD() {
return stateOfDispatchToWD;
}
public void setStateOfDispatchToWD(StateOfDispatchToWD stateOfDispatchToWD) {
this.stateOfDispatchToWD = stateOfDispatchToWD;
}
and method:
public boolean isSuccessfullySentToWD() {
return zoj.getStateOfDispatchToWD() == StateOfDispatchToWD.SUCCESSFULLY_DISPATCH;
}
and call it from JSF:
<p:outputLabel value="OK"
rendered="#{Z.isSuccessfullySentToWD()}"/>
and sometimes I get:
[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
but why? I'm afraid I don't understand. Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Z的范围可能是错误的,请尝试将其放入会话或应用程序范围
Probably the scope of Z is wrong, try to put it in session or application scope