JSF中页面导航问题(跳转页面问题)<from-action……
目的实现从 search.jsp----跳转---> results.jsp
faces-config.xml中代码如下:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN " "http://java.sun.com/dtd/web-facesconfig_1_1.dtd ">
<faces-config>
<navigation-rule>
<from-view-id> /search.jsp </from-view-id>
<navigation-case>
<from-action> #{search.verify} </from-action>
<from-outcome> hello </from-outcome>
<to-view-id> /results.jsp </to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id> /results.jsp </from-view-id>
</navigation-rule>
<managed-bean>
<managed-bean-name> search </managed-bean-name>
<managed-bean-class> haifeng.search.Search </managed-bean-class>
<managed-bean-scope> session </managed-bean-scope>
<managed-property>
<property-name> queryString </property-name>
<value> faces </value>
</managed-property>
</managed-bean>
</faces-config>
search.jsp中的主要代码如下:
<h:inputText value= "#{search.queryString} " />
<h:commandButton actionListener= "#{search.verify} " action= "hello "
value= "跳转 "> </h:commandButton>
可是无论如何都无法实现跳转,除非我去掉faces-config.xml中的
<from-action> #{search.verify} </from-action> 那一行
请问这是怎么回事啊???
谢谢!!!!!!!!!!!
------解决方案--------------------如果你写上 <from-action> #{search.verify} </from-action> 这一行的话,只有当你在这个方法中进行跳转时才有效,即
public String verify(){
return "hello ";
}时才有效。
程序可修改为:
<h:commandButton action= "#{search.verify} "
value= "跳转 "> </h:commandButton>
public String verify(){
return "hello ";
}
这时就可跳转了。其它时候均不进行跳转