您的位置:首页 > 运维架构 > Tomcat

tomcat怎么设置跟iis那种类似的访问密码

2008-05-24 03:50 561 查看
google_ad_client = "pub-8800625213955058";

/* 336x280, 创建于 07-11-21 */

google_ad_slot = "0989131976";

google_ad_width = 336;

google_ad_height = 280;

//

问题:tomcat怎么设置访问密码?跟iis那种类似的 ?

回答:

例如你要控制对ROOT目录下文件的访问:

首先更改$TOMCAT_HOME/ROOT/WEB-INF/web.xml

1。在<web-app>和</web-app>之间加入

<security-constraint>

<web-resource-collection>

<web-resource-name>Entire Application</web-resource-name>

<url-pattern>/*</url-pattern>

</web-resource-collection>

<auth-constraint>

<!-- NOTE: This role is not present in the default users file -->

<role-name>user</role-name>

</auth-constraint>

</security-constraint>

<!-- Define the Login Configuration for this Application -->

<login-config>

<auth-method>BASIC</auth-method>

<realm-name>TEST ACCESS CONTROL</realm-name>

</login-config>

2。然后在$TOMCAT_HOME/conf/tomcat-users.xml中加入

<user name="user" password="password" roles="user"/>

roles的名字和web.xml中的相对应

在TOMCAT4.03中测试通过
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: