【问题标题】:JSP Form not submittingJSP 表单未提交
【发布时间】:2015-03-13 02:02:19
【问题描述】:

我遇到了一个以前从未遇到过的有趣问题。我有一个遵循 MVC 的 Struts Java 应用程序。在 JSP 表单上,当提交按钮被按下时,它应该发布到一个 servlet。但是,提交按钮不起作用,表单也不会发布。如果我手动键入表单应发布到的 url 并按 enter,则表单将成功发布。

我很茫然,因为我从来没有遇到过这个问题。我的应用程序上的任何表格都不会发布,因此它不是一页独有的。我正在使用JDK1.6.0_43

更令人不安的是,我们的生产系统使用相同的代码,并且运行良好。我已经通过 Eclipse 构建路径更改了 JDK,但没有任何成功。

亲切的问候,

【问题讨论】:

  • 如果您需要帮助,您需要在此处发布一些代码。至少有一个简化版本可以证明您的问题。
  • 看看这个[jsp表单没有提交]stackoverflow.com/questions/15976562/…
  • @SteveK 会在我到达可以提供的位置时执行。我之前没有发布它的原因是我的问题更像是“你们以前遇到过这种情况。”
  • 我们不知所措,也无能为力,因为我们没有看到任何代码!

标签: java jsp model-view-controller


【解决方案1】:
enter code here  <form id="validateForm" name="validateForm" method="post" action="<webbase:encodeUrl>forgotUserValidatePrep.sap</webbase:encodeUrl>">
                              <div class="mod-p-bottom">
                                 <div class="abled">
                                 <div class="form-group">
                                    <label><webbase:message key="page.label.customerID" resource="ccsu_forgotusername"/></label>
                                    <input class="form-control" type="number" 
                                        maxlength="<%=ValidationFactory.getInstance().getCustomerValidator().getAllowedCustNumberLength() %>"  
                                        placeholder="" name="j_customerID" id="j_customerID" 
                                    <% if (validation != null && validation.getCustomerID()!= null && validation.getCustomerID().length() > 0){ %>
                                        value = <%= validation.getCustomerID() %>
                                    <% } else if(request.getAttribute("j_customerID") != null && request.getAttribute("j_customerID").toString().length() > 0){ %>
                                        value = <%= request.getAttribute("j_customerID") %>
                                    <% } %>

                                    />
                                    <%-- <span class="help-inline inputerrortext hide">*Required Field</span>--%>
                                </div>

                                </div>
                                <br />
                                <input type="submit" name="continueButton" id="continue" class="btn btn-primary" 
                                    value="<webbase:message key="button.continue" resource="ccsu_forgotusername"/>"/>


                                <input type="submit" name="cancelButton" id="cancel" class="btn" 
                                    value="<webbase:message key="button.cancel" resource="ccsu_forgotusername"/>"/>



                                <br/>
                                <br/>
                                <div style="font-size: 14px; color: #FF0000; font-weight: bold;"><webbase:message key="page.billCaption" resource="ccsu_registration"/></div>
                                <img src="<%=ThemePath.getInstance().getThemePath(pageContext)%>img/exampleBillImage.png" class="img-responsive" />
                              </div>
                          </form>

表单发布到嗅探 .sap 约定的 servlet。简单地按提交没有效果,但如果我在浏览器中写出 url 并按 enter,它就会提交。

【讨论】:

    【解决方案2】:

    问题已解决。以下是我为解决问题而完成的步骤。

    1. 我已经从现有的 .ear 构建了项目,但由于某些潜在的依赖关系,我无法将新项目部署到 Java 服务器。然后我从 .war 文件构建了一个新项目,并插入了所有必要的 .jars、jsp 等。显然系统也不喜欢这样。这是我注意到提交按钮行为的时候。
    2. 我删除了该项目,然后使用 .war 文件重新构建它并生成了 .ear 文件。然后我从旧的 .ear 文件中取出 application-j2ee-engine.xml 文件并将其插入。
    3. 部署了更改,一切都照常进行。

    我以前从未在 Web 应用程序中遇到过这样的行为。超级奇怪。但话又说回来,它是 SAP!

    【讨论】:

      【解决方案3】:

      在 jsp 中,form action="/youservletnameonly"

      【讨论】:

      • 感谢您的回复。不幸的是,这是不行的。
      猜你喜欢
      • 2013-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多