Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6541964
  • 博文数量: 915
  • 博客积分: 17977
  • 博客等级: 上将
  • 技术积分: 8846
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-26 09:59
个人简介

一个好老好老的老程序员了。

文章分类

全部博文(915)

文章存档

2022年(9)

2021年(13)

2020年(10)

2019年(40)

2018年(88)

2017年(130)

2015年(5)

2014年(12)

2013年(41)

2012年(36)

2011年(272)

2010年(1)

2009年(53)

2008年(65)

2007年(47)

2006年(81)

2005年(12)

分类: 系统运维

2012-04-20 21:16:35

在TOMCAT中,在webapps下的应用程序下的WEB-INF目录下的web.xml中的节中,配置如下信息:

点击(此处)折叠或打开

  1. <!-- Define a security constraint on this application -->
  2. <security-constraint>
  3.   <web-resource-collection>
  4.     <web-resource-name>Entire Application</web-resource-name>
  5.     <url-pattern>/*</url-pattern>
  6.   </web-resource-collection>
  7.   <auth-constraint>
  8.     <!-- This role is not in the default user directory -->
  9.     <role-name>manager</role-name>
  10.   </auth-constraint>
  11. </security-constraint>
  12. <!-- Define the login configuration for this application -->
  13. <!--
  14. <login-config>
  15.   <auth-method>BASIC</auth-method>
  16.   <realm-name>Tomcat Manager Application</realm-name>
  17. </login-config>
  18. -->
  19. <!-- Security roles referenced by this web application -->
  20. <security-role>
  21.   <description>
  22.     The role that is required to log in to the Manager Application
  23.   </description>
  24.   <role-name>manager</role-name>
  25. </security-role>
后,每次在IE中输入TOMCAT的地址后,将会弹出HTTP Authentication窗口,要求输入用户名和密码,而这个用户名和密码配置在tomcat-users.xml中,需要配置一个manager角色和具有这个角色的用户。如:

点击(此处)折叠或打开

  1. <?xml version='1.0' encoding='utf-8'?>
  2. <tomcat-users>
  3.   <role rolename="tomcat"/>
  4.   <role rolename="role1"/>
  5.   <role rolename="manager"/>
  6.   <user username="both" password="tomcat" roles="tomcat,role1"/>
  7.   <user username="tomcat" password="tomcat" roles="tomcat,manager"/>
  8.   <user username="role1" password="tomcat" roles="role1"/>
  9. </tomcat-users>



阅读(4649) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~