Rails 重定向是 GET 或 POST
Rails redirected_to 是 get 或 post
我认为 link_to 将是一个 GET 请求。(如果错误请纠正我)
你能提一下有关 request.post 的事情吗?
The rails redirected_to is get or post
and the link_to is i think will be a GET request.(correct me if am wrong)
And can u please mention something about request.post?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
redirect_to 告诉浏览器向给定的 URL 发出 GET 请求。因此,为了回答您的问题,redirect_to(间接)创建一个 GET 请求,如 link_to。
redirect_to tells the browser to issue a GET-request to the given URL. So to answer your question, redirect_to (indirectly) creates a GET-request, like link_to.
重定向是服务器发送的响应。 GET/POST 由浏览器发送。重定向可以是(服务器!)对 GET 或 POST 的响应。
请求.post?在 Rails 控制器中,如果请求是作为 POST 发出的,则为“true”,在所有其他情况下为“false”。
link_to 创建链接 HTMNL 链接,因此自然它们只能引起 GET 请求 - 只能通过 XHR 或通过可以使浏览器发出 POST 请求。
Redirects are reponses sent by the SERVER. GETs/POSTs are sent by the BROWSER. A redirect can be a (server!) response to either a GET or a POST.
request.post? in Rails controllers is "true" if the request was made as a POST, and "false" in all other cases.
link_to creates link HTMNL links, so naturally they can only cause GET requests - only via XHR or through a can you cause a browser to POST requests.
在 Rails 中,redirect_to(您是指 *redirected_to* 吗?)帮助程序输出指示浏览器移动到另一个页面所需的 HTTP 标头,因此浏览器将对新页面执行 GET 请求地址。
在 HTTP 规范中,无法通过 POST 动词执行重定向。
In Rails, redirect_to (did you mean that with *redirected_to* ?) helper outputs the HTTP header which is needed to instruct browser to move to another page, so the browser will do a GET request to the new address.
In HTTP spec there's no way to perform a redirect via the POST verb.