如何在Wicket 1.5中执行以下操作?
page.getRequestCycle().setRequestTarget(new RedirectRequestTarget("http://www.facebook.com/login.php?api_key="+ _apiKey + "&v=1.0"));
我想使用Wicket 1.5做一个Facebook应用程序,我想在某个时候将用户重定向到Facebook登录页面。在 Migrating to Wicket 1.5 中突出显示了很多内容。
答案 0 :(得分:9)
使用HTTP 302(“暂时移动”):
import org.apache.wicket.request.flow.RedirectToUrlException;
...
throw new RedirectToUrlException(
"http://www.facebook.com/login.php?api_key="+ _apiKey + "&v=1.0");
使用HTTP 301(“永久移动”,SEO友好):
import org.apache.wicket.request.flow.RedirectToUrlException;
import javax.servlet.http.HttpServletResponse;
...
throw new RedirectToUrlException(
"http://www.facebook.com/login.php?api_key="+ _apiKey + "&v=1.0",
HttpServletResponse.SC_MOVED_PERMANENTLY);
答案 1 :(得分:5)
请参阅
org.apache.wicket.request.cycle.RequestCycle.scheduleRequestHandlerAfterCurrent(IRequestHandler)
和
org.apache.wicket.request.http.handler.RedirectRequestHandler.RedirectRequestHandler(String)