JSF页面的跳转问题

Albert_2017 2012-11-26 01:20:42
各位大哥大姐,
小弟初学JSF,做了个例子,如下
通过login.jsp调用backing bean中的verify (#user.Verify)方法 ,成功(success)或者失败(failure)则跳到一个result.jsp页面。可是写完例子后,页面就是无法跳转。faces-config.xml的配置我都看过了,大小写也仔细核对,实在是找不到问题所在。
可是我别外在同一个WEB Project中写了一个例子即MyJsp.jsp 不调用backing bean中的方法,却可以实现跳转。
多谢大家了。
(1)login.jsp代码如下:

<body>
<f:view>
<h:form>

<h3>请输入姓名</h3>
名称:<h:inputText value="#{user.userName }"></h:inputText>
<br/>
<h3>请输入密码</h3>
密码:<h:inputText value="#{user.password }"></h:inputText>
<br/>
输出:<h:outputText value="#{user.errorMessage}"></h:outputText>
<br/>
<br/>
<h:commandButton value="提交" action="#{user.Verify}"></h:commandButton>
</h:form>
</f:view>
</body>
(2)faces-config.xml的配置如下
<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>MyBeans.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/MyJsp.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/result.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>login.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/result.jsp</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/result.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
</faces-config>
...全文
83 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧