龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > JAVA开发 >

Tomcat设置类似IIS的访问密码[组图]

时间:2009-12-23 15:42来源:未知 作者:admin 点击:
分享到:
例如你要控制对ROOT目录下文件的访问:首先更改$TOMCAT_HOME/ROOT/WEB-INF/web.XML !-- frame contents -- !-- /frame contents -- 1.在web-app和/web-app之间加入 security-constraint web-resource-collection web-resource-name

  例如你要控制对ROOT目录下文件的访问:首先更改$TOMCAT_HOME/ROOT/WEB-INF/web.XML

<!-- frame contents -->
<!-- /frame contents -->

  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中测试通过 



  
精彩图集

赞助商链接