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>