【发布时间】:2010-08-04 21:30:16
【问题描述】:
我想调用一个存在于与我的战争不同的战争中的 Servlet。当用户单击按钮时,我们需要调用 servlet 的 post 方法。为了实现这一点,我确实看到了一个略有不同但在这种情况下有效的现有示例。
我使用的是jsf,所以在jsp中有一个h:form,里面有另一个html表单。下面是代码:
<h:form>
<div id="gform" class="column span-20 append-1">
<h:outputText value="Text." /><br/><br/>
<h:commandLink id="addPaymentButton" styleClass="button" onclick='autorenew();return false;'> <span><h:outputText value="Payment Option"/></span> </h:commandLink>
<a id="noThanksButton" href="#"><span><h:outputText value="No Thanks"/></span></a><br/><br/><br/>
<h:outputText style="color:grey" value="Some text" />
<div> </div>
</div>
<form id="hiddenSubmit" method="post" action="https://localhost.myapp.com/myapp/LoginRouter" >
<input type="hidden" name="redirectUrl" value="/myapp/customers/addNewSavedCCInfo.faces"/>
<input type="hidden" name="jump_message" value="IAmJumpingToCC"/>
<input type="hidden" name="jump_url" value="/premiumServices/myPage.htm"/>
<input id="hiddenSubmitButton" type="submit" name="submit" style="display: none" value='' />
</form>
</h:form>
<script language="javascript">
function autorenew(){
window.alert('In js fnt');
document.hiddenSubmit.getElementById('hiddenSubmitButton').click();
window.alert('In js fnt COMPLETE');
return false;
}
因此,当单击按钮时,将执行将表单提交给 servlet 的 javascript。但是我可以在萤火虫中看到我需要提交的第二个表单没有出现。我不确定如何在不同的战争中调用 servlet 类的 post 方法。欢迎任何想法,我真的被困住了!
谢谢。
【问题讨论】: