【问题标题】:Parsing error for spring-security.xml filespring-security.xml 文件的解析错误
【发布时间】:2012-11-26 03:23:36
【问题描述】:

我对 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: 发现以元素 's:ldap-authentication-provider' 开头的无效内容。 '{"http://www.springframework.org/schema/security":any-user-service, "http://www.springframework.org/schema/security":password-encoder}' 之一是预期的。

这是xsd

spring security xsd

【问题讨论】:

    标签: spring-security xsd


    【解决方案1】:

    xsd 表示&lt;s:authentication-manager&gt; 接受authentication-providerldap-authentication-provider 作为子级。所以,删除包裹你的&lt;s:ldap-authentication-provider&gt;&lt;s:authentication-provider&gt;,这样你就可以解决这个问题了。您的最终代码应如下所示:

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

    【讨论】:

      猜你喜欢
      • 2012-06-28
      • 2020-08-09
      • 2018-08-16
      • 2016-02-16
      • 1970-01-01
      • 2015-11-10
      • 1970-01-01
      • 2017-11-18
      • 2012-06-24
      相关资源
      最近更新 更多