【发布时间】:2011-11-19 15:16:13
【问题描述】:
我在 Play 中有一个 create 动作!框架控制器应该返回 HTTP 状态代码 Created 并将客户端重定向到创建对象的位置。
public class SomeController extends Controller {
public static void create() {
Something something = new Something();
something.save();
response.status = StatusCode.CREATED; // Doesn't work!
show(something.id);
}
public static void show(long id) {
render(Something.findById(id));
}
}
另见method chaining in the Play! framework documentation。
上面的代码返回状态码302 Found,而不是201 Created。我该怎么做才能让 Play 返回正确的状态(和 Location 标头)?
【问题讨论】:
标签: java rest playframework http-status-codes playframework-1.x