Tomcat6 -> how to put a project into the root folder?

余生颓废 提交于 2019-12-01 06:26:46

问题


I have a Tomcat6 server on a Linux server. The structure of the webapps directory is:

  • examples
  • host-manager
  • manager
  • ROOT
  • sample

I have a web application running on my localhost on a Tomcat. I created a war file MyProject.war and put it into the webapps directory. Restarting the Tomcat server, the war is extracted and I have this structure:

  • examples
  • host-manager
  • manager
  • MyProject
  • ROOT
  • sample

Calling the URL http://mysubdomain.mysite.com:8080/ I get the Tomcat start page with

If you're seeing this page with a web browser, it means you've setup Tomcat successfully. Congratulations!.

Calling http://mysubdomain.mysite.com:8080/MyProject/ I get the page of my project.

What I want, is that I can access my project with the URL http://mysubdomain.mysite.com:8080/ and not with http://mysubdomain.mysite.com:8080/MyProject/

How can I do this?

Best Regards.

Update I have this in my server.xml:

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
    <Context docBase="MyProject" path="/" />
</Host>

I did it on path with an empty string and / and restart Tomcat. Both does not work. The main directory shows me the Tomcat start page instead of my project. The project is only reachable with ...:8080/MyProject/


回答1:


Delete ROOT folder, rename MyProject.war to ROOT.war and restart.

You can also do it by adding the following line to inside the <Host> entry of /conf/server.xml

<Context docBase="MyProject" path="" />


来源:https://stackoverflow.com/questions/4707583/tomcat6-how-to-put-a-project-into-the-root-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!