1

我们在项目中使用 Spring Framework。如果应用程序超时,则会出现以下错误。出现此错误时如何重定向到登录页面?我可以为此错误配置应用程序上下文吗?

PS.:我们不使用 Spring-Security

 org.springframework.web.HttpSessionRequiredException : Expected session
    attribute 'UserPrinciple'
          at
    org.springframework.web.method.annotation.ModelFactory.initModel(ModelFactory.java:103)
          at
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:614)
          at
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
          at
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
          at
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
          at
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
          at
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
          at
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
          at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
          at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
          at
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
          at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
          at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
          at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
          at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
          at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
          at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
          at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
          at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
          at
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
          at org.apache.coyote.AbstractProtocol
    $AbstractConnectionHandler.process(AbstractProtocol.java:585)
          at org.apache.tomcat.util.net.JIoEndpoint
    $SocketProcessor.run(JIoEndpoint.java:310)
          at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
          at java.util.concurrent.ThreadPoolExecutor
    $Worker.run(ThreadPoolExecutor.java:603)
          at java.lang.Thread.run(Thread.java:722)
4

1 回答 1

0

这可能会帮助你..

<error-page>
        <exception-type>org.springframework.web.HttpSessionRequiredException</exception-type>
        <location>/login.jsp</location>
</error-page> 
于 2013-03-27T13:53:23.930 回答