简体   繁体   English

如何在Grails中进行201重定向?

[英]How can I do a 201 redirect in Grails?

For a more RESTful controller, an action that creates an entity should really return a 201 status code with the location header set, not a 30x status code. 对于更RESTful的控制器, 创建实体的动作应真正返回设置了位置标头的201状态代码,而不是30x状态代码。 I would think that there would be a status parameter on the redirect call, but there isn't. 我认为redirect调用上将有一个status参数,但没有。

So, how can I do a "201 redirect" with Grails? 那么,如何使用Grails进行“ 201重定向”?

A grails redirect by nature is an HTTP 302 status. 本质上,grails重定向是HTTP 302状态。 If you want to return a specific status you can use render(status: 201, ...) . 如果要返回特定状态,可以使用render(status: 201, ...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM