我使用Eclipse Juno,JSF和PrimeFaces(OS Debian)創建了簡單的動態Web項目。我在JBoss AS 7.1服務器(獨立)上部署了我的應用程序。有免費網頁:索引,添加和聯繫。我的導航規則是:從索引到添加和聯繫,從添加到索引和聯繫人,從聯繫人到索引和添加。 Everythings運作良好,但從添加和聯繫頁面我不能去索引。僅當我刷新web瀏覽器(Google Chrome)時,纔會顯示索引頁面。有人遇到同樣的問題嗎?我搜查了它,但沒有找到任何解決方案。非常感謝您的幫助。 這裏是我的文件:
web.xml中
導航規則/案例問題
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>excite-bike</param-value>
</context-param>
<display-name>Example2</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
<welcome-file>add.xhtml</welcome-file>
<welcome-file>contact.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet>
<description>JAX-RS Tools Generated - Do not modify</description>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class></servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
faces-config.xml中:
<managed-bean>
<managed-bean-name>addBean</managed-bean-name>
<managed-bean-class>web.AddBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>menuBean</managed-bean-name>
<managed-bean-class>web.MenuBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>add</from-outcome>
<to-view-id>/add.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>contact</from-outcome>
<to-view-id>/contact.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/add.xhtml</from-view-id>
<navigation-case>
<from-outcome>home</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>contact</from-outcome>
<to-view-id>/contact.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/contact.xhtml</from-view-id>
<navigation-case>
<from-outcome>add</from-outcome>
<to-view-id>/add.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>home</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case>
MenuBean.java:
package web;
import javax.annotation.ManagedBean;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class MenuBean {
public String home(){return "home";}
public String add(){return "add";}
public String contact(){return "contact";}}
<br>
代碼:
<h:form>
<p:tabMenu activeIndex="1">
<p:menuitem value="HOME" icon="ui-icon-star"
action="#{menuBean.home()}" />
<p:menuitem value="ADDS" icon="ui-icon-document"
action="#{menuBean.add()}" />
<p:menuitem value="CONTACT" icon="ui-icon-person"
action="#{menuBean.contact()}" />
</p:tabMenu>
</h:form>
雖然你實際上並沒有回答任擇議定書的問題,在所有的帖子,這基本上我會寫文字,所以肯定+1!但我會解釋一下OP所要求的。 – skuntsel 2013-05-05 16:27:39
@skuntsel謝謝!是的,我認爲這是OP需要聽到的情況,也許不是他想要的 - 可隨意編輯或添加自己的答案,以便我可以+1! :) – elias 2013-05-05 17:48:07