Pivotal TC 默认网站覆盖

Pivotal TC default website override

我有 Spring 工具套件 (3.9.2.RELEASE),它默认带有 Pivotal TC Web 服务器,它是 Apache Tomcat 的一个变体。据我了解,为了为 Tomcat 设置 "default website",您需要修改指向您的应用程序的 'context'。最佳实践可能会说在不同的文件中定义它,但我知道它仍然可以在 'server.xml'.

中完成

我在 STS 中有一个应用程序 ("myApp")。它通常通过 http://localhost:8080/myApp 访问。我想改为在 http://localhost:8080 访问它。

以下是来自 Pivotal TC 的片段 'server.xml'

<Context docBase="myApp" path="/myApp" ... />

我已对其进行了如下修改,但我仍然会到达默认的 Pivotal tc Server Runtime 主页,而不是我自己的主页:

<Context docBase="" path="/myApp"  ... />

我应该在另一个位置应用这些更改以使其生效吗?显然有一点我不明白。

非常感谢您的投入。

查找 tomcat's documentation 您在 Context 元素中提到的两个属性,您会发现:

文档库:

The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file (if this web application is being executed directly from the WAR file). You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.

The value of this field must not be set unless the Context element is defined in server.xml or the docBase is not located under the Host's appBase...

路径

The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts.

This attribute must only be used when statically defining a Context in server.xml. In all other circumstances, the path will be inferred from the filenames used for either the .xml context file or the docBase.

Even when statically defining a Context in server.xml, this attribute must not be set unless either the docBase is not located under the Host's appBase or both deployOnStartup and autoDeploy are false. If this rule is not followed, double deployment is likely to result.

换句话说:您应该修改 path 属性。当您执行此操作时,请确保同时取消部署默认内容,否则这些内容将与您自己的定义发生冲突。

您还会发现 "" 不是有效的 docBase,因为它指定了 WAR 文件或目录。