Wicket:如何重定向到另一个页面? [英] Wicket: how to redirect to another page?

查看:118
本文介绍了Wicket:如何重定向到另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Wicket重定向到另一个页面? IIRC,必须在构造函数中抛出一些异常,但我不记得是哪一个。在此先感谢。

How do I redirect to another page using Wicket? IIRC, some exception has to be thrown in the constructor, but I don't remember which one. Thanks in advance.

推荐答案

投掷 RestartResponseAtInterceptPageException 将会这样做,因为您在自己的答案中注意到,但这实际上是允许在当前页面(通常是授权过程的一部分)进行重定向的系统的一部分。如果那不是你的情况,但你仍然需要做一些中断处理的事情,那么抛出 RestartResponseException 可能会更好。

Throwing a RestartResponseAtInterceptPageException will do it, as you noted in your own answer, but that's really part of a system for allowing a redirect with an eventual continuation at the current page (frequently part of an authorization process). If that's not your situation, but you still have to do something that interrupts processing, it might be better to throw a RestartResponseException.

我知道 RestartResponseAtInterceptPageException 的主要用法是在重定向登录页面过程中。如果您正在使用基于角色的身份验证,则确定您未登录的 IAuthorizationStrategy 的实现将发出已配置的 IUnauthorizedComponentInstantiationListener ,通常是 AuthenticatedWebApplication ,如果您没有登录,则会在重定向到已配置的登录页面时抛出此异常。 (如果您已登录但未经授权,则会发生其他情况......)。

The principal usage that I know of for RestartResponseAtInterceptPageException is in the "redirect to login page" process. If you're using role-based authentication, an implementation of IAuthorizationStrategy on determining that you're not logged in will signal a configured IUnauthorizedComponentInstantiationListener, typically the AuthenticatedWebApplication which throws this exception if you're not logged in, with a redirect to a configured login page. (If you're logged in but unauthorized, something else happens...).

实际重定向由 PageMap ,在这种情况下也会记住您尝试访问的页面。成功登录后,登录页面可以通过调用 continueToOriginalDestination()来要求将您发送到您最初尝试的页面,这是组件并从 PageMap 中检索记住的页面。

The actual redirect is done by the PageMap, which also in this case remembers the page you were trying to go to. After a successful login, the login page can ask to send you to the page you were trying for originally by calling continueToOriginalDestination(), which is a method in Component and retrieves the remembered page from the PageMap.

有一些好的<这个身份验证过程的href =http://wicketstuff.org/wicket14/authentication/ =noreferrer>示例代码,但异常和拦截在某种程度上隐藏在幕后。

There's some good example code for this authentication process, but the exception and intercept are hiding behind the scenes somewhat.

这篇关于Wicket:如何重定向到另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆