错误信息部分如下:401 Unauthorized
You are not authorized to view this page. If you have not changed any configuration files,
please examine the file conf/tomcat-users.xml in your installation.
That file will contain the credentials to let you use this webapp.
You will need to add manager role to the config file listed above. For example:
<role rolename="manager"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
For more information - please see the Manager App HOW-TO.
这个问题是有访问权限造成的,所使用的用户不具有相关权限,解决方法如下:找到 Tomcat 文件下找到 conf 文件
在tomcat-users.xml 中:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<user username="admin" password="admin" roles="manager-gui"/>
</tomcat-users>
注意:我的 Tomcat 是 7.0 版本,roles="manager-gui";Tomcat版本不同,也可能存在 roles="manager",具体视情况而定。
我的问题只改动tomcat-users.xml即解决。
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
在查找前辈方法时,有将 conf文件下 的context.xml 也进行了改动的,代码如下:
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Manager pathname="/manager" debug="0" privileged="true" docBase="/home/oracle/tomcat/apache-tomcat-6.0.18/webapps/manager" />
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
</Context>
如果只改动tomcat-users.xml不能解决问题,可尝试同时修改context.xml (ps: 我尝试了一下同时改,没有解决问题... )。
不对之处欢迎大家指正!谢谢!