前言
从Tomcat官网下载后,启动tomcat成功,但是可能无法登录。对于不同的版本,原因不一样。
Tomcat 6.x/7.x
1.编辑conf/tomcat-users.xml ,加入即可:
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
Tomcat 8.x/9.x
- 编辑 webapps/manager/META-INF/context.xml ,就是把中间那块注释:
<Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
2.编辑conf/tomcat-users.xml ,加入即可:
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>