解決The markup in the document following the root element must be well-formed.


出現問題的代碼:

  

<security-constraint>
    <web-resource-collection>
        <web-resource-name>RegisteredUsers</web-resource-name>
        <url-pattern>/ch06/6.3/6.3.4/security.jsp</url-pattern>
    </web-resource-collection>
    <auth-constraint> <!-- 可以訪問的角色 -->
        <role-name>registered_user</role-name>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>

<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Registered Users</realm-name>
</login-config>

<security-role>
    <role-name>admin</role-name>
</security-role>

<security-role>
    <role-name>registered_user</role-name>
</security-role>

解決方法:

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>RegisteredUsers</web-resource-name>
            <url-pattern>/ch06/6.3/6.3.4/security.jsp</url-pattern>
        </web-resource-collection>
        <auth-constraint> <!-- 可以訪問的角色 -->
            <role-name>registered_user</role-name>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>

    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Registered Users</realm-name>
    </login-config>

    <security-role>
        <role-name>admin</role-name>
    </security-role>

    <security-role>
        <role-name>registered_user</role-name>
    </security-role>
</web-app>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM