如何将我的webapp设置为ROOTfor localhost:8080 [英] How to set my webapp to appear as ROOTfor localhost:8080

查看:246
本文介绍了如何将我的webapp设置为ROOTfor localhost:8080的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Tomcat / webapps目录中有一个webapp。我的应用程序的目录是site,显示为http:localhost:8080 / site



我想让网站显示为 http:// localhost:8080 /



我已阅读文档并尝试创建ROOT.xml文件在我的Tomcat / conf / Catalina / localhost目录中创建一个ROOT上下文路径,但没有连接。



有人可以推我正确的方向?以下是ROOT.xml文件的内容。

 <上下文docBase =sitepath =/> < /语境GT; 


解决方案

获取根本上下文的最简单的方法是简单将应用的目录从 webapps / site 重命名为 webapps / ROOT 并重新启动Tomcat。如果您的默认 webapps 文件夹中已经有一个ROOT应用程序,那么您需要创建另一个主机,因为每个主机可能只有一个根上下文应用程序。



另一个选项(再次,如果您还没有在 webapps 下的ROOT应用程序)将编辑您的 conf / server.xml 文件,并将您的上下文元素添加到默认的< Host> 中:

 < Context path =docBase =site/> 

如果您要创建单独的主机,则需要定义第二个< Host> server.xml 中,例如

 <主机名=anotherhostappBase =webapps_anotherhost>< / Host> 

要上面的工作,您需要创建一个 webapps_anotherhost 文件夹作为默认主机的 webapps 文件夹旁边的兄弟文件夹,然后将WAR放在该文件夹中,作为名为 ROOT 或压缩的WAR命名为 ROOT.war 。然后重新启动Tomcat并浏览您的应用程序 http:// anotherhost:8080 (当然也可以是主机文件条目)。



这些只是众多选项之一。 Tomcat文档对这些东西是相当详细的。您可以在 http://tomcat.apache.org/ 上找到您的Tomcat版本文档。


I've got a webapp in my Tomcat/webapps directory. My app's directory is "site" and is showing as http:localhost:8080/site

I'd like to have the site show as http://localhost:8080/

I've read the docs and tried creating a ROOT.xml file in my Tomcat/conf/Catalina/localhost directory to create a ROOT context path but the connection isn't being made.

Can someone nudge me in the right direction? Here's the content of that ROOT.xml file.

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

解决方案

The easiest approach to getting root context would be to simply rename your app's directory from webapps/site to webapps/ROOT and restart Tomcat. If there's already a ROOT app in your default webapps folder, then you need to create another Host, because there may be only one root context app per Host.

Another option (again, if you don't already have a ROOT app under webapps) would be to edit your conf/server.xml file and add your context element within the default <Host>:

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

If you'd like to create a separate host, then you'll need to define a second <Host> in server.xml, e.g.,

<Host name="anotherhost" appBase="webapps_anotherhost"></Host>

For the above to work, you'd need to create a webapps_anotherhost folder as a sibling folder next to your default host's webapps folder, and then drop your WAR in that folder, either as an exploded directory named ROOT or a compressed WAR named ROOT.war. Then restart Tomcat and browse your application at http://anotherhost:8080 (you'll also a hosts file entry, of course).

These are just a few of the many options. The Tomcat docs are fairly detailed about this stuff. You can find the docs for your version of Tomcat at http://tomcat.apache.org/.

这篇关于如何将我的webapp设置为ROOTfor localhost:8080的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆