Java 413 全头错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19333998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 16:12:32  来源:igfitidea点击:

413 Full HEAD error

javajavascriptgoogle-app-engineservlets

提问by leo

i have made a dynamic blog engine, where multiple authors can publish articles.

我制作了一个动态博客引擎,多个作者可以在其中发布文章。

the author goes to a page where he inputs the 'article' 'description' and 'the whole article' in three <textarea>Then i store all the values in 3 variables and store it in the database via an ajax based request.

作者转到一个页面,他在其中输入了“文章”、“描述”和“整篇文章”三部分<textarea>然后我将所有值存储在 3 个变量中,并通过基于 ajax 的请求将其存储在数据库中。

The Problem: The HttpServerRequest is too large and it gives a 413 FULL Head error, and the request doesnt get through.

问题:HttpServerRequest 太大,它给出了 413 FULL Head 错误,并且请求没有通过。

The Code:

编码:

The HTML:

HTML:

<div class="container">
        <h4 class="text-left">Title:</h4>
        <textarea id="title" rows="2" cols="" ></textarea>
        <br />
        <h4 class="text-left">Description:</h4>
        <textarea id="description" rows="5" cols="" ></textarea>
        <br />
        <h4 class="text-left">Article:</h4>
        <textarea id="article" rows="40" cols="" onkeyup="replaceWordChars(this.value)"></textarea>
        <br />

        <div class="publish btn">Publish</div>
        <br />
        <br />
    </div>

The Script:

剧本:

<script>
    $(function(){
        $('.publish').click(function(){
            title = $('#title').val();
            description = $('#description').val();
            article = $('#article').val();

            $.ajax({
                type:       "get",
                url:        "/articles",
                data:       {action:'add', title:title, description:description, article:article},
                success:    function(code)
                {
                            alert("published"); 
                            window.location="dashboard.jsp";
                }

            }).error(function(){ alert("error"); })
            .complete(function(){ alert("complete"); });

        });

    });
    </script>

The ERROR:

错误:

"NetworkError: 413 FULL head - http:///articles?action=add&title=blah&..........gs.%0A%0A&userId=1"

“网络错误:413 FULL head - http:///articles?action=add&title=blah&.........gs.%0A%0A&userId=1”

The Question:

问题:

Is there an alternate way to send a big server request?? I also read on google that we can change the size, to match huge requests?

有没有其他方法可以发送大型服务器请求?我还在谷歌上读到我们可以改变大小,以匹配巨大的请求?

Answers are preferred in java, HTML, javascript (or) jQuery

答案首选 java、HTML、javascript(或)jQuery

EDITI read herethat we can set the size limit of post request in header? How can i do it in GAE?

编辑在这里读到我们可以在标题中设置发布请求的大小限制?我怎样才能在 GAE 中做到这一点?

采纳答案by nanofarad

Don't use HEAD or GET for large parameters. Those should only be used for idempotent requests(repeating it doesn't break anything), and requests that only retrieve data(i.e. searching or filtering a product database) anyway.

不要对大参数使用 HEAD 或 GET。那些应该只用于幂等请求(重复它不会破坏任何东西),以及无论如何只检索数据(即搜索或过滤产品数据库)的请求。

Use a POST request instead:

改用 POST 请求:

<script>
    $(function(){
        $('.publish').click(function(){
            title = $('#title').val();
            description = $('#description').val();
            article = $('#article').val();

            $.ajax({
                type:       "post",
                url:        "/articles",
                data:       {action:'add', title:title, description:description, article:article},
                // .... skipped unchanged lines
    </script>

This is a one-line change.

这是单行更改。

On the server, make sure you use doPost()instead of doGet()in the servlet. You can get parameters in a similar fashion.

在服务器上,请确保您在 servlet 中使用doPost()而不是doGet()。您可以以类似的方式获取参数。

回答by ashah

In my case HEADER was full because cookie value was too large for SESSIONID. I deleted all cookie for that site and it worked.

在我的情况下,HEADER 已满,因为 cookie 值对于 SESSIONID 来说太大了。我删除了该站点的所有 cookie 并且它起作用了。