Struts2传递的隐藏参数在<a href="" onclick=""

时间:2017-08-08 10:36:06

标签: javascript forms struts2

="" I find my issue in Struts2 submit form. If I have below code, it works for passing hidden variable to action.

<s:form action="hiddenAction" id="hiddenForm">
<s:hidden name="method" value="displaylogonForm" id="doMethod"/>
<s:submit name="submit" value="submit"/>
</s:form>

But below does not work in javascript to call. it can go to backend code. But method value is null and even if I request.getparameter("method") , also null. Am I correct? Is there any other method to be able to use a onclick()???

<s:form action="hiddenAction" id="hiddenForm">
<s:hidden name="method" value="displaylogonForm" id="doMethod"/>
<a href="" onclick="submitForm(); return false;"...../>
</s:form>

<script>
function submitForm(){
document.getElementById("hiddenForm").submit();
}</script>

0 个答案:

没有答案