我下面有以下两页。
你好.xhtml,由 .../hello.jsf url 呈现。
<h:form>
<h:commandButton id="submit" value="Submit" action="response"/>
</h:form>
响应.xhtml,由 .../response.jsf url 呈现。
<h:form>
<h:commandButton id="back" value="Back" action="hello"/>
</h:form>
单击“提交”按钮后,hello 页面将重定向到响应页面,但 url 保持不变,即 url 仍然是 .../hello.jsf。
我希望网址是.../response.jsf单击“提交”按钮后。有什么帮助吗?
非常感谢!
如果您实际上没有使用 kolossus 所暗示的老式 JSF 导航案例,而是使用新的 JSF2 隐式导航功能,那么只需添加faces-redirect=true
结果的查询字符串参数。
<h:form>
<h:commandButton id="submit" value="Submit" action="response?faces-redirect=true" />
</h:form>
However,如果您根本不需要调用任何 bean 操作,并且打算使用普通的页面到页面导航,那么为此执行 POST 请求是没有意义的。只需使用<h:button>
then.
<h:button id="submit" value="Submit" outcome="response" />
也可以看看:
- h:button 和 h:commandButton 之间的区别 https://stackoverflow.com/questions/13070537/difference-between-hbutton-and-hcommandbutton
- 什么时候应该使用 h:outputLink 而不是 h:commandLink? https://stackoverflow.com/questions/4317684/when-should-i-use-houtputlink-instead-of-hcommandlink/4317723#4317723
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)