Request-URI太大错误-摆脱GET吗? [英] Request-URI Too Large Error - Get rid of GET?
问题描述
我的网站上有一个表单,用户可以在该表单中提交答案文本,以供控制器检查.
它使用标准的GET形式:
I have a form on my site where users can submit answer text to be checked by the controller.
It uses a standard GET form:
<%= form_tag('/submit', method: "get", remote: true) do %>
但是我最近在长答案中遇到了以下错误:
But I recently got the following error on long answer:
请求URI太大
WEBrick :: HTTPStatus :: RequestURITooLarge
Request-URI Too Large
WEBrick::HTTPStatus::RequestURITooLarge
我应该将表格更改为POST来修复错误吗?这还需要其他更改吗?
Should I change the form to POST to fix the error? Would this require any other changes?
推荐答案
它取决于浏览器/Web服务器,但URL的平均限制为2000个字符.所以是的,如果您达到极限,则将其更改为POST.
It depends on the browser / web server, but the average limit for a URL is 2000 characters. So yes, if you are hitting the limit change it to POST.
这将需要更改表单标签:
This will require changing the form tag:
<%= form_tag('/submit', method: "post", remote: true) do %>
根据您当前的路由,它可能还需要更新您的路由:(因为在默认情况下,使用resources
时POST请求会路由到控制器中的create
方法)
Depending on your current routing, it might also require updating your route: ( since when using resources
POST requests by default are routed to the create
method in your controller )
match '/submit', to: 'submit#index', via: :post
这篇关于Request-URI太大错误-摆脱GET吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!