Spring security 尝试使用会话管理时出错

Spring security 尝试使用会话管理时出错,spring-security,Spring Security,我正在尝试将会话管理放在我的安全应用程序.xml文件中 错误: 发现以元素“会话管理”开头的无效内容。“{”之一http://www.springframework.org/schema/security“:截取url, 我试着去其他地方,但没有成功 建议 ------------------------更新一------------------------ 我试过: <security:session-management invalid-session-url="/logonTime

我正在尝试将
会话管理
放在我的
安全应用程序.xml
文件中

错误:

发现以元素“会话管理”开头的无效内容。“{”之一http://www.springframework.org/schema/security“:截取url,

我试着去其他地方,但没有成功

建议

------------------------更新一------------------------

我试过:

<security:session-management invalid-session-url="/logonTimeOut.jsp">
            <security:concurrency-control expired-url="/logonTimeOut.jsp"/>
        </security:session-management>


它仍然不工作。

我认为您的xml配置不正确。请像这样更改xml配置

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="
        http://www.springframework.org/schema/security 
        http://www.springframework.org/schema/security/spring-security-4.2.xsd
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-4.3.xsd"
>

    <http create-session="always" use-expressions="true">
        <intercept-url pattern="/anonymous*" access="isAnonymous()"/>
        <intercept-url pattern="/login*" access="permitAll"/>
        <intercept-url pattern="/**" access="isAuthenticated()"/>

        <csrf disabled="true"/>

        <form-login login-page='/login.html' authentication-success-handler-ref="myAuthenticationSuccessHandler" authentication-failure-url="/login.html?error=true"/>

        <logout delete-cookies="JSESSIONID"/>
        <remember-me key="uniqueAndSecret" token-validity-seconds="86400"/>

        <session-management invalid-session-url="/invalidSession.html">
            <concurrency-control max-sessions="2" expired-url="/sessionExpired.html"/>
        </session-management>

    </http>

    <beans:bean id="myAuthenticationSuccessHandler" class="org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler"/>

    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="user1" password="user1Pass" authorities="ROLE_USER"/>
                <user name="admin1" password="admin1Pass" authorities="ROLE_ADMIN"/>
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans:beans>


不起作用,因此我尝试了`
,但仍然没有转到该页面。我还需要启用CSRF。这对我来说似乎是一个XML架构验证错误。请将整个XML和整个错误消息添加到您的问题中。特别是命名空间声明将非常重要。例如,带有
xmlns:s的行安全性=…