在Tomcat中出现403访问被拒绝的错误。

8

我在tomcat-users.xml文件中有以下内容:

<tomcat-users>
<role rolename="admin"/>
<role rolename="manager"/>
<user username="aname" password="apassword" roles="admin,manager"/>
</tomcat-users>

如果我访问 http://localhost:8080/manager/html,会要求我输入用户名和密码(据我所知,这些信息来自于tomcat-users.xml),但是当我输入它们后,出现了以下错误:

403 Access Denied
You are not authorized to view this page.

If you have already configured the Manager application to allow access and you have used your browsers back button...

什么可能导致这种行为?提前感谢。
1个回答

23

要使用Web管理界面,您需要添加gui角色

[Tomcat安装路径]/conf/tomcat-users.xml中,您可以定义角色并将其分配给用户。例如:

<tomcat-users>
    <role rolename="admin"/>
    <role rolename="admin-gui"/>
    <role rolename="manager"/>
    <role rolename="manager-gui"/>

    <user username="name" password="pwd" roles="admin,admin-gui,manager,manager-gui"/>
</tomcat-users>

注意:

你可能没有在这里定义任何默认的用户名和密码,所以最好花时间进行配置,否则当使用像NetBeans这样的IDE中集成的Tomcat时会遇到问题。确实,为了正确使用Tomcat,它需要这些凭据。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接