Spring安全会话管理和Spring MVC视图解析程序错误

Spring安全会话管理和Spring MVC视图解析程序错误,spring,spring-mvc,session,spring-security,Spring,Spring Mvc,Session,Spring Security,我正在开发一个SpringMVCWeb应用程序。上周我开始在我的项目中添加SpingSecuirty。我面临的问题与会话管理有关。 这是我的spring-security.xml的http部分 <http auto-config="true"> <intercept-url pattern="/css" filters="none"/> <intercept-url pattern="/js" filters="none"/&

我正在开发一个SpringMVCWeb应用程序。上周我开始在我的项目中添加SpingSecuirty。我面临的问题与会话管理有关。 这是我的spring-security.xml的http部分

    <http auto-config="true">
        <intercept-url pattern="/css" filters="none"/>
        <intercept-url pattern="/js" filters="none"/>
        <intercept-url pattern="/logout" filters="none"/>
        <intercept-url pattern="/loginfailed" filters="none"/>
        <intercept-url pattern="/login" filters="none"/>
        <intercept-url pattern="/**" access="ROLE_USER" />
        <form-login login-page="/login" default-target-url="/hello"
        authentication-failure-url="/loginfailed" />
        <session-management invalid-session-url="/login.jsp?error=sessionExpired" session-authentication-error-url="/login.jsp?error=alreadyLogin">
           <concurrency-control max-sessions="1"  expired-url="/login.jsp?error=sessionExpiredDuplicateLogin" error-if-maximum-exceeded="false"/>
        </session-management>
    </http>

登录/注销工作正常,但当我尝试从不同浏览器登录以使用户会话无效时,无效会话url=“/Login.jsp?error=sessionExpired”失败。浏览器被重定向,因为我看到正在发送对login.jsp?error=sessionExpired的get请求。但是,网页显示错误,表示资源不可用。我怀疑这与

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass">
    <value>org.springframework.web.servlet.view.JstlView</value>
  </property>
  <property name="prefix">
    <value>/WEB-INF/pages/</value>
  </property>
  <property name="suffix">
    <value>.jsp</value>
  </property>
</bean>

org.springframework.web.servlet.view.JstlView
/WEB-INF/pages/
.jsp

在我的dispatcher-servlet.xml中。但是,我不知道如何解决这个问题。login.jsp位于WEB-INF/pages/

中,您正在重定向到jsp,而不是映射的url

会话管理标签应为:

<session-management invalid-session-url="/login?error=sessionExpired" session-authentication-error-url="/login?error=alreadyLogin">
       <concurrency-control max-sessions="1"  expired-url="/login?error=sessionExpiredDuplicateLogin" error-if-maximum-exceeded="false"/>
</session-management>


在我看来,Spring MVC DispatcherServlet无法找到/login.jsp的映射,因为。我还假设您已经将/login映射到login.jsp(您没有提供足够的信息来确认这一点),但是如果是这种情况,只需使用
过期url即可=“/login?error=sessionExpiredDuplicateLogin

谢谢你!很好!顺便说一句,我在试图理解无效会话url、会话身份验证错误url和过期url之间的区别时有些不知所措。我知道有文档,但你还是可以给我指一个可以提供更详细信息的资源。