解决tomcat localhost:8080 404

最近用到maven 与tomcat集成,在集成中,发现tomcat怎么都访问不了localhost:8080主页,很是郁闷.(本人使用的是非安装版本的tomcat_7)
开始排除.
  首先排除端口问题.查看conf\server.xml
 
 <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

  后面有配置了系统变量
  tomcat_home=D:\software\tomcat_7\apache-tomcat-7.0.47
  java_path据说是不需要在非安装版本的tomcat中配置的,你只需要配置系统变量就行.
  最后还是无解.
  最后我无意间比较压缩包中的文件与解压后的文件发现webapps下面少了几个文件夹.
 
  原来我不小心清空webapps下面的文件夹,所以当你访问localhost:8080时,也就是访问root下面的文件.
  这时当你在运行,startup.bat就可以看到你熟悉的tomcat首页.
 
  如果你想进入manager app你还需要根据以下信息更改你的tomcat-user.xml文件
 
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 must contain the credentials to let you use this webapp.

For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.

<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Note that for Tomcat 7 onwards, the roles required to use the manager application were changed from the single manager role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access.

manager-gui - allows access to the HTML GUI and the status pages
manager-script - allows access to the text interface and the status pages
manager-jmx - allows access to the JMX proxy and the status pages
manager-status - allows access to the status pages only
The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection:

Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles.
If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session.
For more information - please see the Manager App HOW-TO.



添加如下
<role rolename="manager-gui"/>
<user username="tomcat" password="123456" roles="manager-gui"/>

猜你喜欢

转载自a151555.iteye.com/blog/1982227