spring-security.xml文件的解析错误

时间:2012-12-07 22:03:37

标签: spring-security xsd

我对xml知之甚少,我必须编写一个spring-security.xml文件。我想这个问题与我的xml没有关注xsd有关。这是xml。

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:s="http://www.springframework.org/schema/security"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <s:http auto-config="true">
                <s:intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" />
                <s:intercept-url pattern="/index.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY" />
        <s:intercept-url pattern="/**" access="ROLE_USER" />
                <s:intercept-url pattern="/" access="ROLE_USER" />       
        <s:form-login login-page="/login" default-target-url="/getemp"/>
        <s:logout logout-success-url="/logout" />
    </s:http>

    <s:authentication-manager>
        <s:authentication-provider>

                        <s:ldap-authentication-provider user-dn-pattern="uid={0},ou=people"/>
        </s:authentication-provider>
    </s:authentication-manager>

        <s:ldap-server id="ldapServer" url="ldap://test.com:389" />

</beans>

当我尝试运行Web应用程序时,我收到错误。

引起:org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:从元素的开头找到了无效的内容:ldap-authentication-provider'。其中一个'{“http://www.springframework.org/schema/security":any-user-service,,http://www.springframework.org/schema/security":password_encoder}'是预期的。

这是xsd

spring security xsd

1 个答案:

答案 0 :(得分:3)

xsd表示<s:authentication-manager>作为孩子接受authentication-providerldap-authentication-provider。因此,请删除包含<s:authentication-provider>的{​​{1}},这样可以解决您的问题。您的最终代码应如下所示:

<s:ldap-authentication-provider>
相关问题