我正在尝试使用 Play向客户端发送303 See Other
带有Location
标头和响应正文的详细信息,详细说明它们被重定向的原因(这似乎允许每 RFC 26162.3.10
) :
package example;
import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.Results;
public class SeeOtherExample extends Controller {
public Result seeOtherExample() {
response().setHeader(LOCATION, "http://example.com");
return Results.status(SEE_OTHER, "You were redirected because...");
}
}
但是当我包含位置标头时,响应正文返回空。省略标题会导致正确返回正文,但当然我也需要标题。
此外,它似乎是关于Location
标题的特定内容。设置其他标题不会导致正文被省略。
发回Location
标头和响应正文的最佳方式是什么?