简体   繁体   English

在Struts 1.2中使用JavaScript提交表单

[英]Form submit using JavaScript in Struts 1.2

I am using Struts in my application. 我在我的应用程序中使用Struts。

I am trying to submit a form using javascript. 我正在尝试使用javascript提交表单。 Hence I did this in html file: 因此我在html文件中这样做:

<html:form name="returnForm" action="/returnMedia">

and this in <script> tag: 这在<script>标签中:

document.forms["returnForm"].submit();

This is normally what we do while submitting a form using javascript. 这通常是我们在使用javascript提交表单时所做的事情。

But in struts 1.2, I am getting an exception, asking me to set the type for the form also. 但是在struts 1.2中,我遇到了异常,要求我也为表单设置类型。

Checking the docs, it seems this is not the correct way to submit the form in struts 1.2. 检查文档,似乎这不是在struts 1.2中提交表单的正确方法。

Please let me know how to proceed with this. 请让我知道如何处理这个问题。

Thanks, 谢谢,

how about this 这个怎么样

{
document.forms[0].action = "UserAction.do?method=add"
document.forms[0].submit();

}

look at this link http://www.dzone.com/tutorials/java/struts/struts-example/struts-dispatch-action-example-1.html 看看这个链接http://www.dzone.com/tutorials/java/struts/struts-example/struts-dispatch-action-example-1.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM