我正在尝试配置 Tomcat 7 JDBC 领域配置。我完全按照本教程进行操作: http ://www.avajava.com/tutorials/lessons/how-do-i-use-a-jdbc-realm-with-tomcat-and-mysql.html
我收到基本身份验证弹出窗口,但即使我输入正确的凭据,用户也未通过身份验证。我没有收到任何错误消息。
教程指定 Tomcat 5.5,但我使用的是 Tomcat 7。我刚刚更改了动态 Web 项目的connectionPasword
和connectionName
和名称。
这是server.xml
JDBC 领域配置
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/tomcat_realm"
connectionName="root"
connectionPassword="root"
userTable="tomcat_users"
userNameCol="user_name"
userCredCol="password"
userRoleTable="tomcat_users_roles"
roleNameCol="role_name" />
这是web.xml
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>test.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>Wildcard means whole app requires authentication</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>dude</role-name>
</auth-constraint>
<user-data-constraint>
<!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE -->
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
我所能看到的是,我收到了有关安全性的消息:
Security role name dude used in an <auth-constraint> without being defined in a <security-role>
你能帮我解决这个问题吗?这个问题与Tomcat 7有关吗?