Java – how to set the context path in Tomcat so that you can enter the site without attaching the deployed folder name?

I read some questions about this in the Tomcat guide here I think I do almost the same thing But to some extent, it can't succeed

First, I have to say that my application is deployed on a shared Tomcat server beyond my control I just gave up my War file, which is deployed

I tried to package my application as root War, but it doesn't work The administrator told me to wrap it in any name I wanted and they would take care of it I packed it into my application War, it is deployed, but I have to enter http://my-host/my-application To access the site

After contacting the administrator, they told me that they placed a context element in the host in the Tomcat configuration file, such as:

<Context path="" docBase="path of my-application deployed folder"/>

This should set my application as the default application for all requests to my host But no, whenever I enter http://my-host I get:

HTTP Status 404 - / The requested resource (/) is not available

But when I enter http://my-host/my-application All this can work normally Any suggestion about what might be wrong is absolutely appreciated

Update: I tried to follow the steps described in the Tomcat document in April 2007. Three methods were described. I tried all three methods and successfully deployed my application as root on the local host

I also try to reproduce the problem I face on the remote server, so I can find the cause and report it to the administrator I found a few questions

>In the server sent to me by the administrator In the XML fragment, autodeploy and deployonstartup are set to true, and if in server If context elements are explicitly defined in XML, they should be false This will result in a dual deployment, which creates a root folder with the name The folder of the war file Delete War will delete its corresponding folder and unconfigure the application, but the root remains unchanged, must be deleted manually, and tomcat.com needs to be restarted Before restarting, any root The deployment of war will fail. > I think there are some reasons to stop root War deployment One may be root XML exists in conf / {engine name} / {host name}, or a root folder exists in the appbase of the host, or as mentioned above, the root application in the previous deployment has not been undeployed, and Tomcat needs to restart

Either way, I can't accurately determine what is preventing root War deployment, because it needs to access Tomcat log file and conf file to check the above situation

Also from all I see, my administrator seems unable to maintain a Tomcat server and find the problem So I decided to share one with a dedicated Tomcat server

Solution

In your question, you declared that the administrator set the context to:

<Context path="" docBase="path of my-application deployed folder"/>

Based on the above comments, I suggest trying to use the relative path of the application instead of the absolute path

I tried on the Tomcat server:

<Context path="/" docBase="my-application/" />

I did

The host element containing the context element actually sets some parameters that may also affect the context If it is the default setting, the relative context should only point to the webapps folder If changed, the results may be different

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>