使用控制器中的 redirect() 方法似乎可以重定向到内部 URL。
public static Result index() {
return redirect(routes.Application.tasks());
}
但是我想重定向到控制器中的外部 URL。redirect(String) 方法只接受内部 URL 作为参数。
我需要的是相当于标准 Java servlet 重定向的 Play 框架,即
request.sendRedirect(String url)
使用控制器中的 redirect() 方法似乎可以重定向到内部 URL。
public static Result index() {
return redirect(routes.Application.tasks());
}
但是我想重定向到控制器中的外部 URL。redirect(String) 方法只接受内部 URL 作为参数。
我需要的是相当于标准 Java servlet 重定向的 Play 框架,即
request.sendRedirect(String url)
有时最简单的解决方案只是......有效:
return redirect("http://stackoverflow.com/questions/10962694");
也值得使用其他可用的重定向,例如
seeOther(String url)movedPermanently(String url)temporaryRedirect(String url)ETC