【问题标题】:Form submit using JavaScript in Struts 1.2在 Struts 1.2 中使用 JavaScript 提交表单
【发布时间】:2013-02-15 17:19:16
【问题描述】:

我在我的应用程序中使用 Struts。

我正在尝试使用 javascript 提交表单。因此我在 html 文件中这样做了:

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

这在&lt;script&gt;标签中:

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

这通常是我们在使用 javascript 提交表单时所做的。

但是在 struts 1.2 中,我遇到了一个异常,要求我也设置表单的类型。

检查文档,看来这不是在 struts 1.2 中提交表单的正确方法。

请告诉我如何处理。

谢谢,

【问题讨论】:

  • 你的例外是什么?你的 struts-config 是什么?
  • 听起来更像是你的action配置不正确。

标签: java javascript struts-1 struts1


【解决方案1】:

这个怎么样

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

}

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

【讨论】:

    猜你喜欢
    • 2015-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-26
    • 2016-01-04
    • 2014-01-04
    相关资源
    最近更新 更多