您好我正在尝试在我的jsf2(Primefaces)中应用prettyFaces来重写我的网址。我的页面有一个用于导航的菜单栏。这是代码 名为menu.xhtml
<p:menubar id="unique">
<p:menuitem value="Accueil" url="/faces/../index.xhtml" icon="ui-icon-home"/>
<p:submenu label="Données" icon="ui-icon-folder-collapsed">
<p:menuitem value="Catégories" url="/faces/../categories/categories.xhtml" icon="ui-icon-document" />
<p:menuitem value="Articles" url="/faces/../articles/articles.xhtml" icon="ui-icon-plus" />
</p:submenu>
<p:menuitem value="Prestataires" url="/faces/../prestataires/prestataires.xhtml" icon="ui-icon-suitcase"/>
<p:menuitem value="Bon de Commande" url="/faces/../commandes/commandes.xhtml" icon="ui-icon-suitcase"/>
<p:submenu label="Personnel" icon="ui-icon-folder-collapsed">
<p:menuitem value="Services" url="/faces/../services/services.xhtml" icon="ui-icon-document" />
<p:menuitem value="Personnel" url="/faces/../personnels/personnels.xhtml" icon="ui-icon-plus" />
</p:submenu>
<p:submenu label="Sorties" icon="ui-icon-folder-collapsed">
<p:menuitem value="Ordre de sortie" url="/faces/../ordresorties/ordresorties.xhtml" icon="ui-icon-document" />
<p:menuitem value="Bon de sortie" url="/faces/../bonsorties/bonsorties.xhtml" icon="ui-icon-plus" />
</p:submenu>
<p:menuitem value="Utilisateurs" url="/faces/../utilisateurs/utilisateurs.xhtml" icon="ui-icon-person"/>
</p:menubar>
我想要使用prettyfaces重写这些网址。这是我的漂亮配置
的内容漂亮-config.xml中
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config- prettyfaces" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces http://ocpsoft.org/xml/ns/prettyfaces/rewrite- config-prettyfaces.xsd">
<url-mapping id="cate">
<pattern value="/categories" />
<view-id value="/faces/../categories/categories.xhtml" />
</url-mapping>
<url-mapping id="arti">
<pattern value="/articles" />
<view-id value="/faces/../articles/articles.xhtml" />
</url-mapping>
<url-mapping id="presta">
<pattern value="/prestataires" />
<view-id value="/faces/../prestataires/prestataires.xhtml" />
</url-mapping>
<url-mapping id="bonCommandes">
<pattern value="/bonCommandes" />
<view-id value="/faces/../commandes/commandes.xhtml" />
</url-mapping>
<url-mapping id="serv">
<pattern value="/services" />
<view-id value="/faces/../services/services.xhtml" />
</url-mapping>
<url-mapping id="perso">
<pattern value="/personnesl" />
<view-id value="/faces/../personnels/personnels.xhtml" />
</url-mapping>
<url-mapping id="bonSorti">
<pattern value="/bonSortie" />
<view-id value="/faces/../bonsorties/bonsorties.xhtml" />
</url-mapping>
<url-mapping id="ordreSort">
<pattern value="/ordreSortie" />
<view-id value="/faces/../ordresorties/ordresorties.xhtml" />
</url-mapping>
<url-mapping id="utilis">
<pattern value="/utilisateurs" />
<view-id value="/faces/../utilisateurs/utilisateurs.xhtml" />
</url-mapping>
<url-mapping id="login">
<pattern value="/" />
<view-id value="/faces/../login.xhtml" />
</url-mapping>
<url-mapping id="accueil">
<pattern value="/accueil" />
<view-id value="/faces/../index.xhtml" />
</url-mapping>
</pretty-config>
当我运行我的应用程序时,只有accueil网址正常。当我试图打开更好的页面时,我在导航器中出现了这个错误:
Etat HTTP 404 - /utilisateurs/login.xhtml Not Found in ExternalContext as a Resource
这里我试图打开menu.xhtml文件中提到的url /utilisateurs/utilisateurs.xhtml。我不明白为什么它打开/utilisateurs/login.whtml
请帮助。
答案 0 :(得分:0)
将您的网址设置为模式值减去&#34; /&#34;。即:
<p:menuitem value="Accueil" url="index" icon="ui-icon-home"/>
对我有用。