解决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>