Jsf 带有POST参数的FacesContext重定向
我需要使用POST参数将页面重定向到外部站点,但我不能像这里所解释的那样使用普通HTMLJsf 带有POST参数的FacesContext重定向,jsf,jsf-2,Jsf,Jsf 2,我需要使用POST参数将页面重定向到外部站点,但我不能像这里所解释的那样使用普通HTML: 因为那样的话,表单就会在jsf表单中,而且它不起作用 是否可以使用: FacesContext.getCurrentInstance().getExternalContext().redirect("http://example.com"); 有POST参数,但没有额外的普通形式?或者,也许有其他方法可以做到这一点,而不需要形式?试试这样的方法: JAVASCRIPT: function redire
:
因为那样的话,表单就会在jsf表单中,而且它不起作用
是否可以使用:
FacesContext.getCurrentInstance().getExternalContext().redirect("http://example.com");
有POST参数,但没有额外的普通形式?或者,也许有其他方法可以做到这一点,而不需要形式?试试这样的方法: JAVASCRIPT:
function redirect() {
document.getElementById("mySubmitButton").submit();
}
function redirect(dynamicValue) {
document.getElementById("dynamicField").value = dynamicValue;
document.getElementById("mySubmitButton").submit();
}
XHTML:
<h:form>
<span onclick="javascript:redirect()" class="linkClass">REDIRECT</span>
</h:form>
<div style="display:none:"> <!-- If you want it hidden -->
<form action="http://external/myplace.html" method="post">
<input type="hidden" value="value1"></input>
<input type="submit" id="mySubmitButton"</input>
</form>
</div>
<h:form>
<span onclick="javascript:redirect('myValue')" class="linkClass">REDIRECT</span>
</h:form>
<div style="display:none:"> <!-- If you want it hidden -->
<form action="http://external/myplace.html" method="post">
<input id="dynamicField" type="hidden" value=""></input>
<input type="hidden" value="value1"></input>
<input type="submit" id="mySubmitButton"</input>
</form>
</div>
XHTML:
<h:form>
<span onclick="javascript:redirect()" class="linkClass">REDIRECT</span>
</h:form>
<div style="display:none:"> <!-- If you want it hidden -->
<form action="http://external/myplace.html" method="post">
<input type="hidden" value="value1"></input>
<input type="submit" id="mySubmitButton"</input>
</form>
</div>
<h:form>
<span onclick="javascript:redirect('myValue')" class="linkClass">REDIRECT</span>
</h:form>
<div style="display:none:"> <!-- If you want it hidden -->
<form action="http://external/myplace.html" method="post">
<input id="dynamicField" type="hidden" value=""></input>
<input type="hidden" value="value1"></input>
<input type="submit" id="mySubmitButton"</input>
</form>
</div>
重新使用
我知道你在主HTML中有一个表单,在里面你想做重定向。您可以在外部创建另一个表单并使用javascript调用它。这是一个很好的主意,但问题是我需要为表中每行的项目动态创建几个按钮。每个按钮都发送不同的参数?也许您可以实现JS函数来接收这些参数并对表单进行动态修改,或者,如果差异只是URL,则传递URL。您是否看到这个@freak-我想重定向到外部站点-因此我既不能使用cookie也不能使用会话。我喜欢这个解决方案,但如何根据我按下的按钮传递不同的值?我需要从表中传递一个值-#{v.value}。@robson我添加了另一个传递参数的版本,我希望这就是你想要的:)@BalusC-你有更好的吗?@BalusC-我不需要JSF-你是对的,但我需要摆脱表单-因为我已经在一个中了,所以-我认为maqjav的解决方案在我的情况下很有用。这就是为什么我想尝试FacesContext重定向-尝试重定向到第一个表单中的另一个页面,但我需要的是传递POST参数。