JSF 2.0中的显式URL重定向 [英] Explicit url redirect in JSF 2.0
问题描述
我在下面有以下两页.
hello.xhtml ,由.../hello.jsf网址呈现.
hello.xhtml, rendered by .../hello.jsf url.
<h:form>
<h:commandButton id="submit" value="Submit" action="response"/>
</h:form>
response.xhtml ,由.../response.jsf网址呈现.
response.xhtml, rendered by .../response.jsf url.
<h:form>
<h:commandButton id="back" value="Back" action="hello"/>
</h:form>
单击提交"按钮时,问候页面将重定向到响应页面,但URL保持不变,即url仍为.../hello.jsf.
When Submit button is clicked, the hello page is redirected to the response page but the url remains the same, i.e., the url is still .../hello.jsf.
点击提交"按钮后,我希望该网址为 .../response.jsf .有什么帮助吗?
I'd like the url to be .../response.jsf after the Submit button is clicked. Any help, please?
非常感谢!
推荐答案
将redirect
属性添加到您的faces_config.xml
文件中,如下所示:
Add the redirect
attribute to your faces_config.xml
file like so:
<navigation-rule>
<from-view-id>/hello.xhtml</from-view-id>
<navigation-case>
<from-outcome>response</from-outcome>
<to-view-id>/response.xhtml</to-view-id>
<!--the redirect element -->
<redirect/>
</navigation-case>
</navigation-rule>
从您的导航结果样式中,我得到的印象是您正在使用faces-config.xml
.我已经亲自确认,对于新的JSF 2样式导航,您所做的事情也是允许的.有关在JSF2样式的导航处理中使用redirect
url参数的信息,请参阅BalusC的答案.
I got the impression that you're using a faces-config.xml
from your navigation outcome styling. I have confirmed personally that what you're doing is also permissible for the new JSF 2 style navigation. See BalusC's answer for using the redirect
url parameter in a JSF2-style navigation handling
这篇关于JSF 2.0中的显式URL重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!