我制作了一个动态博客引擎,多位作者可以在其中发表文章。
作者进入一个页面,输入三个<textarea>中的“文章”描述和“整篇文章”,然后我将所有的值存储在3个变量中,并通过基于ajax的请求将其存储在数据库中。
问题是: HttpServerRequest太大了,它给出了413个完整的头错误,而请求没有通过。
“守则”:
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>剧本:
<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>错误:
NetworkError: 413全头-http:///articles?action=add&title=blah&..........gs.%0A%0A&userId=1
问题是:
是否有其他方式发送大服务器请求??我还在谷歌上读到,我们可以改变大小,以满足巨大的要求?
在java、HTML、javascript (或) jQuery中首选答案。
编辑我读here,我们可以在标题中设置post请求的大小限制吗?我怎么才能在GAE里做到呢?
发布于 2013-10-12 12:10:53
不要使用HEAD或GET作为大参数。这些应该只用于幂等请求(重复它不会破坏任何东西),以及只检索数据的请求(即搜索或过滤产品数据库)。
使用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>这是单行的零钱。
在服务器上,确保在servlet中使用doPost()而不是doGet()。您可以以类似的方式获得参数。
发布于 2017-09-06 13:04:24
在我的例子中,头部是满的,因为cookie值对于SESSIONID来说太大了。我把那个网站的所有曲奇都删除了,而且成功了。
https://stackoverflow.com/questions/19333998
复制相似问题