Spring boot始终从index.html提供服务

问题描述 投票:0回答:1

我用angular-cli创建了一个spring boot项目。输出jar文件如下所示:

BOOT-INF
    |- classes
        |- com
        |- static
            |- index.html

现在,当我转到以下网址时

http://<ip>:<port>

我被重定向到http://<ip>:<port>/app1,因为在我的角度路线中,我将其配置为重定向。

但是当我尝试刷新http://<ip>:<port>/app1时,我找不到404。

angular spring-boot
1个回答
-1
投票

Spring Boot会自动检测以下位置index.html中的public/static/webapp

如果您有任何控制器专门编写了这样的映射 - > @Requestmapping("/")它将覆盖默认行为,除非您路由到index.html,否则它不会显示http:\\localhost:8080\index.html

您可能希望在此文件夹结构下创建它

src/main/resources/public/index.html

希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.