tomcat修改用户名

来源:互联网 发布:java类加载过程 编辑:程序博客网 时间:2024/05/16 15:40

点击Manager App会让你输入用户名和密码,该用户名和密码是要在conf目录中的tomcat-users.xml中配置的

打开tomcat-users.xml,在<tomcat-users>标签下添加如下配置

<role rolename="tomcat"/>
<!--<role rolename="manager"/>
<role rolename="admin"/>-->
<user username="test" password="test" roles="tomcat"/>

<user>标签中的用户名和密码就是需要输入的用户名和密码

但是这样配置是不够的,还需要在webapp/manager/WEB-INF/web.xml中的

配置中进行修改

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>HTML Manager interface (for humans)</web-resource-name>
      <url-pattern>/html/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
       <role-name>tomcat</role-name>//需要修改的地方
    </auth-constraint>
  </security-constraint>

 

 <auth-constraint>
       <role-name>tomcat</role-name>//需要修改的地方
       <role-name>manager-script</role-name>
       <role-name>manager-jmx</role-name>
       <role-name>manager-status</role-name>
    </auth-constraint>

 

 <security-role>
    <description>
      The role that is required to access the HTML Manager pages
    </description>
    <role-name>tomcat</role-name>//需要修改的地方
  </security-role>

这样修改之后就可以用了

如果觉得文章写的还不错,那么就评论一下吧,有问题的话可以留言!!!