【发布时间】:2014-09-24 23:59:30
【问题描述】:
我正在使用 Pretty Faces 进行 URL 重写,以便能够重用一些 xhtml 文件。我想让像'/honda/index.xhtml'和'/toyota/index.xhtml'这样的URL都进入同一个/make/index.xhtml文件,make作为参数进入。这个路由似乎可以在这样的配置中正常工作:
<url-mapping id="carMake">
<pattern value="/#{make}/index.xhtml"></pattern>
<view-id value="/make/index.xhtml"/>
</url-mapping>
对于搜索结果类型的页面,我也有此映射:
<url-mapping id="search">
<pattern value="/#{make}/search/index.xhtml" />
<view-id value="/search/index.xhtml" />
</url-mapping>
当我手动将 URL 放入浏览器时,这两项工作都按预期工作。
当我尝试将表单放在第一页时遇到问题,我想重定向到第二页。我有一个表单的这个 jsf xhtml 代码:
<h:form>
<h:messages />
<h:inputText id="searchTerm"/>
<h:commandButton value="search" action="/honda/search/index.xhtml?faces-redirect=true"/>
</h:form>
(硬编码/honda这里是为了简化例子)
当我尝试提交此搜索时,它会弹回相同的 /honda/index.xhtml,页面上没有显示任何消息。
日志显示:
09-23 11:39:55 DEBUG PrettyNavigationHandler:57 - Navigation requested: fromAction [/honda/search/index.xhtml?faces-redirect=true], outcome [/honda/search/index.xhtml?faces-redirect=true]
09-23 11:39:55 DEBUG PrettyNavigationHandler:60 - Not a PrettyFaces navigation string - passing control to default nav-handler
我已经尝试不使用 faces-redirect 参数,但得到了相同的结果。
为什么当我直接将 /honda/search/index.xhtml 放入浏览器时它可以工作,而不是作为操作的结果?
【问题讨论】:
标签: jsf-2 prettyfaces