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.blogjava.net/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2010-09-17 09:55
zhyiwww 阅读(861)
评论(0) 编辑 收藏 所属分类:
j2ee