【问题标题】:sending long strings in jquery post在 jquery post 中发送长字符串
【发布时间】:2012-05-21 06:48:57
【问题描述】:

我无法在 jquery post 方法中发送长字符串(超过 96 个字符。在 FF12 和 Chrome 18 中测试)。 我的 servlet 是 -

public class TestServletAsh extends HttpServlet{
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
        super.doPost(req, resp);
        String xml=req.getParameter("xml");
    }
}

我的 jquery 发布请求是 -

<body>
<script>
    function callMe() {
        var str = "dkghjkdf dfg jdfgjd gkdfgdjk gdf gdfg dkjgdfjk gdjgdfjg dfjkgdfjkg dfjkgdfjkg dfjkgdf jkdfgdjhgs";
        $.post(
            "TestServletAsh",
            { xml:str },
            function(data) {
                alert("mission successfull");   //nothing to do with it or data here in this SO question
            }
        );
    }
</script>
<a href="javascript:void(0)" onclick="callMe()">Click to send request</a>
</body>

我正在调试 servlet,发现“xml=null”。我正在使用 jboss 作为网络服务器。 谁能告诉我问题出在哪里。

当我像这样使用另一个版本的 jquery.post 时 -

$.post(
    "TestServletAsh?xml="+str,
    function(data) {
        alert("mission successfull");   //nothing to do with it or data here in this SO question
    }
);

然后我可以发送大约 6000 个字符。对于 6000 多个字符,Firebug 说 - “405 Aborted”。为什么 ??有什么想法吗?

【问题讨论】:

  • @Andreas - 请检查问题的最后一部分。我已经更新了。

标签: javascript jquery html servlets


【解决方案1】:

可能是您的网络服务器,即 Jboss 可能是问题所在。 您可以查看更改服务器配置参数

尝试在 conf/server.xml 文件中设置 maxPostSize = 0

【讨论】:

    猜你喜欢
    • 2011-06-30
    • 1970-01-01
    • 2015-02-11
    • 2014-10-31
    • 1970-01-01
    • 2017-01-04
    • 2018-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多