chalice 2.0.0 : HTTP status 302

标签 grails post controller get httpresponse

我有一个 Controller ,它只允许对某些操作进行 POST:

static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

然后有一个测试:
void testUpdateWithGet() {
    controller.update()
    assert response.status == HttpServletResponse.SC_METHOD_NOT_ALLOWED
} 

这在 2.0.0.RC1 中运行良好,但在升级到 Grails 2.0.0 最终版本后,响应中的返回状态为 302 .这是为什么?

问候

乔纳斯

最佳答案

我可以确认你的测试用例。这是因为从 2.0.0.RC3 开始,Grails 也存在影响 2.0.0 最终版本的未解决错误:http://jira.grails.org/browse/GRAILS-8426 - 允许的方法在单元测试中不受尊重。您可以降级到 2.0.0.RC1 或等待修复此错误。它只影响单元测试,但在应用程序中工作正常。

关于 chalice 2.0.0 : HTTP status 302,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8597921/

相关文章:

exception - Grails - 停止/取消上传时出现异常

grails - 如何在Web服务器上编译包括Grails插件项目的Grails应用程序?

grails - 在CMD上运行Grails 3应用程序时出错

http - 发送 POST 请求时出现意外的 EOF

mysql - 500 启动新用户 session 时生产适配器 rails 出错

grails - Grails域hasMany验证

python - "WARNING:tornado.access:405"停止来自 "localhost"和 "file://"源的 POST 时出错

http - 使用 Grails 的简单 GET

ruby-on-rails - rails 4.1.6 在似乎未显示的 rake route 添加索引

controller - 访问另一个 Controller 类中的 Controller