【发布时间】:2013-01-21 18:29:31
【问题描述】:
<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 应用程序。
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
标签: jsf