Login JSF2登录实现
我试图用JSF2(使用NetBeans)实现一个非常基本的(此时)登录屏幕。我已经找到了几个例子,我从中复制了源代码,但到目前为止没有成功。 在我的login.xhtml文件中,我有两个输入字段和一个命令按钮-Login JSF2登录实现,login,jsf-2,faces-config,Login,Jsf 2,Faces Config,我试图用JSF2(使用NetBeans)实现一个非常基本的(此时)登录屏幕。我已经找到了几个例子,我从中复制了源代码,但到目前为止没有成功。 在我的login.xhtml文件中,我有两个输入字段和一个命令按钮- <h:commandButton value="go!" actionListener="#{LoginBean.CheckValidUser}" /> 在我的faces-config.xml中,我添加了以下导航规则: <navigation-rule>
<h:commandButton value="go!" actionListener="#{LoginBean.CheckValidUser}" />
在我的faces-config.xml中,我添加了以下导航规则:
<navigation-rule>
<description>login success</description>
<from-view-id>/login.xhtml</from-view-id>
<navigation-case>
<from-action>#{LoginBean.CheckValidUser}</from-action>
<from-outcome>welcome</from-outcome>
<to-view-id>/welcome.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
登录成功
/login.xhtml
#{LoginBean.CheckValidUser}
欢迎
/welcome.xhtml
无论如何,我只是不工作,我输入了正确的UN和PW,但我没有进入“welcome.xhtml”。当我调试代码时,我在验证函数中看到它按预期工作,但是我可以知道faces-config.xml配置正确吗
我错过了什么?
干杯
埃雷斯这里
<h:commandButton value="go!" actionListener="#{LoginBean.CheckValidUser}" />
动作侦听器应该返回void
,并且不打算导航
另见:
与具体问题无关,请将
一起删除。这是不必要的,因为JSF2.0提供了新的隐式导航支持。“welcome”
的结果将隐式转到“welcome.xhtml”
。确保您阅读的是JSF2.x目标资源/书籍/教程,而不是JSF1.x。与JSF1.x相比,JSF2.x是一个重大变化
另见:
<h:commandButton value="go!" actionListener="#{LoginBean.CheckValidUser}" />
<h:commandButton value="go!" action="#{LoginBean.CheckValidUser}" />