【问题标题】:POST data sent by Spring MVC is null on IE8Spring MVC 发送的 POST 数据在 IE8 上为空
【发布时间】:2011-04-07 16:36:21
【问题描述】:

我在 Spring MVC 中有两个文本字段(pageField1)和 pageField2),用户可以在其中输入页码。 javascript 代码检索这些文本字段中的值并作为 POST 数据发送到控制器。用于在 javascript 中检索值并作为 POST 数据发送的代码对于这两个字段完全相同。

在控制器中,我使用 request.getParameter("value") 来检索 POST 数据。 在 Firefox 和 Chrome 上,可以正常检索 pageField1 和 pageField2 的值。 在 IE8 上,request.getParameter("value") 为 pageField1 返回 null,但为 pageField2 返回正确的值。

这真是莫名其妙,我被难住了。我在 Spring MVC 将 POST 数据发送到控制器之前发出了警报。 FireFox 和 IE 的值完全相同,但在控制器上检索时,在 IE 上为 null。

任何输入都会很棒!如果需要,我可以发布代码的 sn-p。

谢谢!

【问题讨论】:

  • 很多可能出错的地方。您可以尝试在没有 javascript 的情况下提交您的表单吗?您可以尝试 httptea (httptea.sourceforge.net) 查看从不同浏览器发送的所有标头信息。我的直觉是,您用于发布表单的 javascript 没有为 IE 8 正确设置参数,因此该参数甚至没有发送到您的服务器。
  • 我同意@hooknc。请发布执行 POST 请求的 javascript 代码。没有代码无法调试。

标签: java spring-mvc


【解决方案1】:

将尝试使用 HTTPtea。我已经下载了,现在只需要配置它。 谢谢!!这是我的 JavaScript 代码: 下面是 JavaScript 代码:

functionPageField1(event){
    if (event == null || event.keyCode == 13) {
      var domain = document.getElementById('domainTextField').value;
      var nameToFindExcl = document.getElementById('searchObjectsExclTextField').value;
      var pageNumberExcl = document.getElementById('pageNumberExclTextField').value;
      var pageCountExcl = document.getElementById('pageCountExclTextField').value;
      var nameToFindIncl = document.getElementById('searchObjectsInclTextField').value;
      var pageNumberIncl = document.getElementById('pageNumberInclTextField').value;
      if (!isValidInput(pageNumberExcl,pageNumberIncl)){
        return;
      }

      alert("/sysmgr/domains/viewDomainObjects.spr?domain=" + domain + "&nameToFindExcl=" + nameToFindExcl +
        "&pageNumberExcl=" + pageNumberExcl + "&nameToFindIncl=" + nameToFindIncl + "&pageNumberIncl=" + pageNumberIncl);

      /* Its the pageNumberExcl that is null in the controller, where as all other 
         values are fine.
         In the above alert, I see the correct value for pageNumberExcl, but its null when I retreive it in the controller. 
      */
      window.location="/sysmgr/domains/viewDomainObjects.spr?domain=" + domain + "&nameToFindExcl=" + nameToFindExcl +
        "&pageNumberExcl=" + pageNumberExcl + "&nameToFindIncl=" + nameToFindIncl + "&pageNumberIncl=" + pageNumberIncl;
    }
  }

 //This is the snippet of the html code that defines the pageNumberExcl Field
 <td>
            <p align="right">
              <fmt:message key="form.any.page"/> <input type="text" id="pageNumberExclTextField"
                value="${pageNumberExcl}" size="3" onKeyPress="numberPageExcl(event)">
              <fmt:message key="form.any.of"/> <input disabled type="text" style="border-style:none; background-color:white; color:black"
                id="pageCountExclTextField" value="${pageCountExcl}" size="3">
            </p>
 </td>`

【讨论】:

    猜你喜欢
    • 2011-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2013-06-21
    相关资源
    最近更新 更多