问题描述
我刚刚创建了我的web项目(JSP / Servlets)的war文件。
I 've just created war file of my web project (JSP/Servlets).
项目名称:TestApp
当我在Tomcat 7中保留它时,我运行它:
when I deply it in Tomcat 7, I run itlike that:
localhost:8080 / TestApp / 或 www.maypage.com/testApp /
好的,一切正常,但是我需要在没有项目名称的情况下运行它,例如:
ok, everything works, but I need to run it without project name, like that:
localhost :8080 并主持 www.maypage.com
我该怎么做?
谢谢。
How can I do that?thank you.
我正在罚款jsp / servlet托管,它有配置选项。你知道这样的托管吗?
And I'm fining jsp/servlet hosting, which have that configuration option. do you know hosting like that?
推荐答案
为了在不使用应用程序名称的情况下访问你的应用程序,你需要将其部署为根应用程序。有多种方法可以实现它,相关的答案很好地描述了它。
In order to access your application without using the application name, you need to deploy it as the root application. There are multiple ways to achieve it and the related answer describes it pretty well.
从上述链接复制的内容:
Content copied from the above link:
首先关闭你的tomcat [来自bin目录( sh shutdown.sh)]
然后你必须删除你的tomcat webapps文件夹的所有内容(rm
-fr *),然后将你的WAR文件重命名为ROOT.war,最后启动你的tomcat [来自bin目录(sh startup.sh)]
first shutdown your tomcat [from the bin directory (sh shutdown.sh)] then you must delete all the content of your tomcat webapps folder (rm -fr *) then rename your WAR file to ROOT.war finally start your tomcat [from the bin directory (sh startup.sh)]
第二种方法:
离开你的战争CATALINA_BASE / webapps中的文件,其原始名称为
- 在server.xml文件的Host元素中关闭autoDeploy和deployOnStartup。在
server.xml中明确定义所有应用程序上下文,同时指定path和docBase。你必须这样做,
,因为你已经禁用了所有的Tomcat自动部署机制,并且
Tomcat将不再部署你的应用程序,除非它在server.xml中找到他们的
Context。
leave your war file in CATALINA_BASE/webapps, under its original name - turn off autoDeploy and deployOnStartup in your Host element in the server.xml file. explicitly define all application Contexts in server.xml, specifying both path and docBase. You must do this, because you have disabled all the Tomcat auto-deploy mechanisms, and Tomcat will not deploy your applications anymore unless it finds their Context in the server.xml.
注意:
这最后一个方法也暗示为了对
任何应用程序进行任何更改,你必须停止并重新启动Tomcat。
that this last method also implies that in order to make any change to any application, you will have to stop and restart Tomcat.
第三种方法:
将您的war文件放在CATALINA_BASE / webapps之外(必须在
外面以防止双重部署)。 - 在CATALINA_BASE / conf //中放置一个名为
ROOT.xml的上下文文件。这个上下文中的单个元素
文件必须有一个指向
war文件位置的docBase属性。不应设置path元素 - 它是从.xml文件的
名称派生的,在本例中为ROOT.xml。有关详细信息,请参阅上面的上下文
容器。
Place your war file outside of CATALINA_BASE/webapps (it must be outside to prevent double deployment). - Place a context file named ROOT.xml in CATALINA_BASE/conf//. The single element in this context file MUST have a docBase attribute pointing to the location of your war file. The path element should not be set - it is derived from the name of the .xml file, in this case ROOT.xml. See the Context Container above for details.
这篇关于在Tomcat上部署war文件并在没有项目名称的情况下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!