Post/Redirect/Get:Get 被多次调用
我有一个网页,其中有一个通过 POST 提交的表单。此 POST 路由处理一些数据并将用户重定向到 GET 路由。问题:GET 路由被调用多次,通常为 3 次。因此,三个 GET 被触发,用户看到的是第一个 GET 请求。我可以在日志中看到另外两个 GET 请求。
有时甚至会发生 GET 被调用超过 3 次的情况...
(当然 POST 路由只被调用一次...)
顺便说一句,我在 Jetty 上使用 JRuby/JRack/Sinatra (-> Google App)引擎。)问题发生在本地和远程。
菲利普
I have a webpage which has a form that is submitted via POST. This POST-route processes some data and redirects the User to a GET route. The problem: The GET route is called multiple times, usually 3 times. So three GET's are fired and the user see's the first GET request. The other two GET requests I can just see on my logs.
Occasionally it even happens that the GET is called more than three times...
(Of course the POST route is just called once...)
By the way I'm using JRuby/JRack/Sinatra on Jetty (-> Google App Engine.) The problem happens locally and remotely.
Philip
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我之前的代码中也遇到过同样的问题(尽管平台不同)。事实证明,页面中的元素引用了与页面相同的 url。我有 1 个损坏的图像和 2 个被忽略的已设置到父页面的 css 文件。
如果是同类问题,可以使用Firebug的net选项卡来验证和调试。
I have had that same issue in my code before (although different platform). It turned out to be elements in the page referencing the same url as the page. I had 1 broken image and 2 ignored css files that had been set to the parent page.
If it's the same kind of issue you can use Firebug's net tab to verify and debug.
如果没有看到代码则不确定,但在大多数情况下,脚本将在调用重定向函数后继续执行。尝试在调用redirect_to后立即从您的方法返回。
Not sure without seeing the code, but in most cases a script will continue to execute after a call to a redirect function. Try returning from your method immediately after calling redirect_to.
您的代码中存在逻辑错误。修复它。
There is a logical bug in your code. Fix it.