我一直在尝试在tomcat中设置约束资源。出于某种原因,tomcat不使用tomcat-users.xml中定义的用户。这里是web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<session-config>
<session-timeout>20</session-timeout>
</session-config>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>Admin</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>AdminResource</web-resource-name>
<url-pattern>/admins/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
</security-constraint>
</web-app>
在tomcat-users.xml中,我定义了角色和一个用户对其进行测试:
<role rolename="Admin" />
<user username="Barracuda121" password="arslan198198" roles="Admin" />
可能是问题所在,如何至少看到容器抛出的异常?我尝试制作jsp错误页面,但异常对象为null。我使用的是tomcat Apache Tomcat 8.0.27随NetBeans提供。