如何修复对Tomcat中被拒绝的请求资源的访问?

Sta*_*ust 5 authentication configuration tomcat http-status-code-403 catalina

我想通过使用数据库作为领域来启用基于表单的身份验证,但每当我尝试在Tomcat 6中作为Tomcat管理器进行身份验证时,我总是收到该消息.我已经创建了一个表user_name和user_roles并将用户名(蓝色)映射到admin和manager作为mysql中user_roles表中的角色,但我仍然无法进行身份验证.我已经在server.xml文件中重新创建了realm标记:

 <Realm className      = "org.apache.catalina.realm.JDBCRealm"
        debug          = "99" 
        driverName     = "com.mysql.jdbc.Driver"
        connectionURL  = "jdbc:mysql://localhost:3306/mail" 
        connectionName = "root" 
        userTable      = "users"
        userNameCol    = "user_name"
        userCredCol    = "user_pass"
        userRoleTable  = "user_roles" 
        roleNameCol    = "role_name" 
 /> 
Run Code Online (Sandbox Code Playgroud)

谁能告诉我我在做什么,以及如何使用数据库启用基于表单的身份验证?

  1. 我已经将用户"蓝色"声明为管理员和经理,当我尝试登录tomcat管理器页面时,它给我的消息是:

    HTTP状态403 - 拒绝访问所请求的资源

  2. 当我输入错误的用户名或密码时,tomcat再次要求输入用户名和密码,而不是显示该消息.

Jos*_*seK 3

我自己没试过这个。您可以尝试更改 中的 auth-method 以TOMCAT_HOME_DIR\webapps\manager\WEB-INF\web.xml将 auth-method 设置为 FORM。领域名称并不重要。

<login-config>   <auth-method>FORM</auth-method>   <realm-name>Tomcat Manager Application</realm-name> </login-config>
Run Code Online (Sandbox Code Playgroud)

另外只需确认 - 您必须在 server.xml 中仅保留一个 Realm,注释掉默认的 Realm。