如何在Play Framework 2.0(Java)中重定向到外部URL [英] How to redirect to external URL in Play framework 2.0 (Java)
本文介绍了如何在Play Framework 2.0(Java)中重定向到外部URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过使用控制器中的redirect()方法,似乎可以重定向到内部URL.
Redirecting to an internal URL seems to be possible by using the redirect() method in the controller.
public static Result index() {
return redirect(routes.Application.tasks());
}
但是,我想重定向到控制器中的外部URL. redirect(String)方法仅接受内部URL作为参数.
However I want to redirect to an external URL in the controller. redirect(String) method accepts only internal URLs as parameter.
我需要的是等效于标准Java servlet重定向的Play框架
What I require is Play framework equivalent of standard Java servlet redirect i.e.
request.sendRedirect(String url)
推荐答案
有时最简单的解决方案就可以...
Sometimes simplest solution just... works:
return redirect("http://stackoverflow.com/questions/10962694");
同样值得使用其他可用重定向,例如
-
seeOther(String url)
-
movedPermanently(String url)
-
temporaryRedirect(String url)
seeOther(String url)
movedPermanently(String url)
temporaryRedirect(String url)
等
这篇关于如何在Play Framework 2.0(Java)中重定向到外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文