eclipse - Pivotal TC 默认网站覆盖

标签 eclipse tomcat spring-tool-suite

我有 Spring Tool Suite (3.9.2.RELEASE),默认情况下它与 Pivotal TC Web 服务器一起提供,它是 Apache Tomcat 的一个变体。据我了解,为了为 Tomcat 设置“默认网站”,您修改了指向您的应用程序的“上下文”。最佳实践可能会说在不同的文件中定义它,但我知道它仍然可以在“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 文件或目录。

关于eclipse - Pivotal TC 默认网站覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48872290/

相关文章:

java - 在 Web 上下文根之外动态编译和包含 JSP(X)

java - Jersey Hello World 给出 404

java - Spring Integration Java DSL流的STS可视化

java - m2eclipse 如何制作一个网络应用程序

java - 使用 Eclipse BIRT 报告引擎在 Web 应用程序中生成 Word 文档

java - ProcessBuilder 无法在 java eclipse luna 中正确执行程序

java - eclipse maven项目如何配置热部署

java - WAR 不会部署到 Tomcat 7.0.19

eclipse - "display" View 在 "Spring Tool Suite Version: 3.9.6.RELEASE"中的任何视角下均不可见

java - Spring 工具套件 : Changes to static resources triggers redeploy