2012-06-18 66 views
6

我已經中tomcat-users.xml如下:403訪問在Tomcat中拒絕

<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... 

什麼可能是這種行爲的原因?提前致謝。

回答

21

要使用web管理gui,您必須添加gui role

[Tomcat installation path]/conf/tomcat-users.xml中,您可以定義role並將它們影響到user。例如:

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

注:

您可能沒有任何默認的用戶名和密碼這裏定義所以它總是好的花時間做這個配置或使用集成在IDE中的Tomcat(如NetBeans)時會遇到問題。事實上,它需要這些證書才能正確使用它。

+0

謝謝,它的工作。你應該在這裏的第三行添加'>'。 –

+0

不客氣,謝謝'''我沒見過! –