有过jsf页面编程的朋友应该都会碰到这个问题,即当面页面所属的地址与浏览器地址栏显示器的地址不一致,地址栏上显示的总是慢一拍。一开始我也为这事烦了好久,后来不经意在一本书上看到了类似的处理办法:
首先,在web-inf下新建一个faces-config.xml的配置文件(如果原本有的话就不必了)。
然后在里面配置导航规则;假设我有两个页面 /page1.xhtml、/page2.xhtml,另外,我在page1.xhtml中有一个按钮<h:CommandButton value = “按钮" action = "/page2" />,即我要从page1跳转到page2页面,此时在faces-config.xml的配置如下:
<?xml version="1.0" encoding="utf-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
.........
.........
<navigation-rule>
<from-view-id>/page1.xhtml</from-view-id>
<navigation-case>
<from-outcome>/page2</from-outcome>
<to-view-id>/page2.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
</faces-config>