在jquery帖子中发送长字符串 [英] sending long strings in jquery post

查看:73
本文介绍了在jquery帖子中发送长字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am not able to send long strings (more than 96 char. Tested in FF12 and Chrome 18) in jquery post method. My servlet is -

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帖子请求是 -

and my jquery post request is -

<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作为网络服务器。
任何人都可以告诉我问题在哪里。

I am debugging the servlet and I find "xml=null". I am using jboss as a webserver. Can anyone please tell me where is the problem.

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

When I use another version of jquery.post like this -

$.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。为什么?有什么想法吗?

Then I am able to send around 6000 characters. For more than 6000 characters Firebug says - "405 Aborted". Why ?? Any idea ?

推荐答案

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

May be your webserver i.e. Jboss could be the issue. You can look into changing server config parameters

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

Try setting maxPostSize = 0 in conf/server.xml file

这篇关于在jquery帖子中发送长字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆