[英]Can't seem to figure out how to redirect to a .xhtml using primefaces
我的主頁WebContent文件夾中有一個index.xhtml文件。 在那里,我可以將一些數據發送到控制器,該控制器隨后將重定向到WEB-INF / jsf /中的list.xhtml文件。 list.xhtml位於WEB-INF / jsf /中,因此如果不從索引頁發送數據就無法訪問它。
無論如何,從index.xhtml到list.xhtml的重定向都可以正常工作( <p:commandButton />
並對控制器執行操作)。 問題是從list.xhtml導航回index.xhtml。 不管我做什么,似乎都行不通。
到目前為止,我已經嘗試過:
<h:button value="Go Back" outcome="index.xhtml" />
-按鈕顯示為灰色,顯示消息This button is disabled because a navigation case could not be matched
。 假設這是因為它正在WEB-INF / jsf /中搜索index.xhtml
<h:button value="Go Back" outcome="../../index.xhtml" />
-與上述相同
<p:commandButton value="Go Back" action="#{listController.goBack}" />
和action="#{goBackController.goBack}"
-使用goBack()方法返回與上一個結果值相同的東西例子
如果有人可以向正確的方向推動我,那將不勝感激。
我也知道網頁不應該真正位於WEB-INF中,但是我不知道如何隱藏list.xhtml頁面。
您需要了解關於outcome
兩件事:
.xhtml
作為一個值outcome
。 例如,如果頁面名稱是Example.xhtml
,則正確的方法是outcome="Example"
。 http://yourdomain.com/app/folder/Page1.xhtml
,如果單擊帶有outcome="Page2"
的按鈕,則您將到達http://yourdomain.com/app/folder/Page2.xhtml
。 您不能在outcome
使用../
導航到父文件夾。 嘗試這個:
<p:button value="Go back" href="../../index.xhtml" />
如果不起作用,則在href
放置絕對路徑即可完成這項工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.