Eclipse / Tomcat:可以访问tomcat主页但是app不是

时间:2018-02-07 15:47:26

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

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

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

但是,我的应用“tutorial-web-spring”无法作为localhost:8080/tutorial-web-spring triggers 404进入。

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

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

1 个答案:

答案 0 :(得分:0)

上下文路径 默认情况下,上下文路径为“/”。如果那不理想,你需要改变它 - 到tutorial-web-spring,这是通过application.properties(spring bot App)快速而简单的方法:

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