gpt4 book ai didi

java - 无法在 Spring Boot 上设置静态网站

转载 作者:行者123 更新时间:2023-12-02 11:52:01 26 4
gpt4 key购买 nike

根据Spring Boot Documentation

By default Spring Boot will serve static content from a directory called /static in the classpath or from the root of the ServletContext

我已经在 application.properties 中设置了 spring.mvc.static-path-pattern=/resources/** - 尽管如此,我还是收到了错误 404。

(在名为“dispatcherServlet”的 DispatcherServlet 中未找到带有 URI [/index.html] 的 HTTP 请求的映射)

<小时/>

这是我的项目层次结构:

Project Hierarchy

<小时/>

我错过了什么?

解决方案:

我有一个到 / 的 Controller 映射,删除它后我可以看到该网站! 捂脸

最佳答案

您是否在没有 spring.mvc.static-path-pattern=/resources/** 的情况下尝试过?或者尝试使用设置的属性来访问 /static/index.html ?因为该设置更改了 Spring Boot 查找静态文件的位置,并且我清楚地看到您的 index.html 位于 resources/static 文件夹中。

关于java - 无法在 Spring Boot 上设置静态网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47820167/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com