00:00 / 13:50
连播
清屏
智能
倍速
点赞17
00:00 / 01:22
连播
清屏
智能
倍速
点赞485
00:00 / 01:35
连播
清屏
智能
倍速
点赞4
00:00 / 02:36
连播
清屏
智能
倍速
点赞1
00:00 / 14:42
连播
清屏
智能
倍速
点赞4
00:00 / 00:17
连播
清屏
智能
倍速
点赞1087
00:00 / 01:28
连播
清屏
智能
倍速
点赞12
00:00 / 03:18
连播
清屏
智能
倍速
点赞4
在Spring Boot项目中,**HTML文件(及CSS、JS等前端资源)的存放位置分两种核心场景**,Java Web相关的后端代码(如Controller、Service)则另有目录,具体如下: ### 1. 静态HTML/前端资源(无需后端渲染,直接访问) 适合纯静态页面(如首页、帮助页,无需后端数据填充),默认放在 **`src/main/resources/static`** 目录下。 - 示例:将`index.html`、`css/style.css`、`js/script.js`放入此目录,启动项目后,可通过浏览器直接访问: `http://localhost:8080/index.html`(无需额外配置,Spring Boot自动映射此目录下的静态资源)。 - 其他默认静态资源目录(较少用):`src/main/resources/public`、`src/main/resources/resources`、`src/main/resources/META-INF/resources`,优先级低于`static`,日常开发优先用`static`即可。 ### 2. 动态HTML模板(需后端渲染,如Thymeleaf) 若HTML需要后端传递数据(如商品详情页、用户中心,需显示数据库数据),需用模板引擎(如Thymeleaf),这类HTML放在 **`src/main/resources/templates`** 目录下。 - 示例:将`productDetail.html`(Thymeleaf模板)放入此目录,需通过Java后端的`Controller`跳转访问: ```java @Controller public class ProductController { @GetMapping("/product") public String showProduct(Model model) { model.addAttribute("productName", "鲜米快装服务"); // 后端传数据 return "productDetail"; // 对应templates/productDetail.html } }
00:00 / 02:34
连播
清屏
智能
倍速
点赞0
00:00 / 16:39
连播
清屏
智能
倍速
点赞3
00:00 / 03:04
连播
清屏
智能
倍速
点赞18
00:00 / 05:19
连播
清屏
智能
倍速
点赞11
00:00 / 05:30
连播
清屏
智能
倍速
点赞7
00:00 / 00:48
连播
清屏
智能
倍速
点赞9