tomcat下basic授權的訪問配置
【1】把下面的代碼放到你在自己項目的<web-app>下面
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<!-- NOTE: This role is not present in the default users file -->
<auth-constraint>
<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-user.xml里面,添加如下代碼
<tomcat-users>
<role rolename="user"/>
<user username="xyz" password="xyz" roles="user"/>
</tomcat-users>
【3】重啟tomcat就可以了
|----------------------------------------------------------------------------------------|
版權聲明 版權所有 @zhyiwww
引用請注明來源 http://www.tkk7.com/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2010-09-17 09:55
zhyiwww 閱讀(865)
評論(0) 編輯 收藏 所屬分類:
j2ee