首页 > 代码库 > 添加tomcat用户-角色验证

添加tomcat用户-角色验证

Tomcat 6.0\conf\tomcat-users.xml目录下添加用户

<tomcat-users>
      <role rolename="manager"/>
      <role rolename="admin"/>

  <role rolename="lluser">  (服务器启动后自动增加的服务器启动后)
      <user username="admin" password="lcp" roles="admin,manager"/>

  <user username="lop" password="lop" roles="admin"/>

     user username="ll" password="lcp" roles="lluser">

</tomcat-users>

完成登录验证还需要配置web-inf/web.xml文件

 <welcome-file-list>        <welcome-file>main.html</welcome-file>   </welcome-file-list>   <security-constraint>        <web-resource-collection>RegisteredUsers</web-resource-collection>        <url-pattern>/count.jsp</url-pattern>        <auth-constraint>            <role-name>lluser</role-name>            <role-name>admin</role-name>        </auth-constraint>   </security-constraint>   <login-config>        <auto-method>BASIC</auto-method>        <realm-name>Registered Users</realm-name>   </login-config>   <security-role>        <role-name>lluser</role-name>   </security-role>   <security-role>        <role-name>admin</role-name>   </security-role>

 

添加tomcat用户-角色验证