Tapestry中防止惡意用戶登陸的方法,即保護頁面的方法
Page的java文件要實現PageValidateListener接口,完成pageValidate(PageEvent event)方法
注意public void pageValidate(PageEvent event) {
if (!getUserExists()) {
Login login = getLoginPage();
login.setNextPage("Confirm");
throw new PageRedirectException(login);
}
}
注意這里要用PageRedirectException方法,因為As the rendering
has begun, calling activate() will have no
effect. To interrupt the rendering of the
current page and render another page,
you need to throw a
PageRedirectException.
這里是服務器內部跳轉
The URL displayed in the
browser will not be changed
because the redirection
happens inside Tapestry
only.
posted on 2007-11-05 11:33 劉錚 閱讀(282) 評論(0) 編輯 收藏 所屬分類: Tapestry