【问题标题】:Eclipse/Tomcat : tomcat home page is reachable but app is notEclipse/Tomcat:tomcat 主页可访问,但应用程序不可访问
【发布时间】:2018-07-17 23:36:46
【问题描述】:

我目前正在尝试在 tomcat 服务器上使用 Eclipse 部署一个简单的 Web 应用程序。

当我通过 Eclipse 启动服务器时,一切看起来都很好。 localhost:8080 工作正常并显示tomcat 主页。

但是,我的应用程序“tutorial-web-spring”无法通过localhost:8080/tutorial-web-spring triggers 404 访问。

我的应用程序已在 eclipse 服务器选项卡上很好地添加到我的服务器中...

顺便说一句,我更改了配置,因此 eclipse 使用 tomcat 安装文件夹而不是工作区元数据。

【问题讨论】:

  • 你使用的是xml配置还是Java配置?
  • 不确定你的意思,但这里的一切都在 xml 中;)
  • 能否请您发布您的属性文件?和配置?

标签: java spring eclipse tomcat http-status-code-404


【解决方案1】:

上下文路径 默认情况下,上下文路径为“/”。如果这不理想并且您需要将其更改为 tutorial-web-spring,这是通过 application.properties(spring bot 应用程序)进行的快速简单的方法:

server.contextPath=/tutorial-web-spring

对于基于 YAML 的配置:

server:
    contextPath:/tutorial-web-spring

最后——也可以通过编程方式进行更改:

@Component
public class CustomizationBean
  implements EmbeddedServletContainerCustomizer {

    @Override
    public void customize(ConfigurableEmbeddedServletContainer container) {
        container.setContextPath("/tutorial-web-spring");
    }
}

SOURCE

【讨论】:

  • “/”路径将我直接发送到 tomcat 主页,而不是我的应用程序
  • 好吧,这些解决方案似乎都不起作用:(相同的结果
  • 编辑:我将部署路径更改为 mytomcat 文件夹位置 /webapps 和 /wtpwebapps(都尝试过),但仍然无法正常工作..
猜你喜欢
  • 2016-11-04
  • 1970-01-01
  • 2013-12-19
  • 2011-05-12
  • 2018-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-16
相关资源
最近更新 更多