如果我的自定义验证在spring安全登录期间失败,则返回自定义jsp



我在应用程序中使用Spring 2.5我的应用程序使用Spring Security进行登录。它有一个实现UserDetailService并重写loadUserByUsername方法的类。

在我的loadUserByUsername中,我正在进行IP验证,如果不成功,我想将用户重定向到自定义JSP页面iperr.JSP。我该怎么做?我尝试在IP验证的情况下抛出异常,并在web.xml中捕获错误,如:

    <error-page>
        <exception-type>com.salebuild.model.IPNotFoundException</exception-type>
        <location>/WEB-INF/errors/ip_activation_required.jsp</location>
    </error-page>

但我不起作用。有人能建议我如何在我的自定义异常上返回一个自定义JSP吗。

Yuo可以尝试抛出AccessDeniedException,并使用错误jsp 设置带有errorPage属性的accessDeniedHandler

最新更新