-2
<pre><h:form>
<h:panelGrid>
<h:outputLabel value="Username: " style="font-weight:bold" />
<h:inputText value="#{user.username}" />
<h:outputLabel value="Password: " style="font-weight:bold" />
<h:inputSecret value="#{user.password}" />
<h:commandButton value="Submit" action="#{user.doLogin()}" />
</h:panelGrid>
</h:form>
</pre>
有人解釋我爲什麼會導致異常?這是我的第一個JSF應用程序。JSF空指針異常
ava.lang.NullPointerException
at userSession.getUsername(userSession.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
'userSession#getUsername'方法有錯誤。請提供託管的bean代碼以獲得更好的幫助。此外,請指定您是否使用JSF 1.x或JSF 2.x –