├─pom.xml
│
└──src
└─main
├─java
│ └─com.example.demo
│ ├─SpringBootLab01Application.java
│ │
│ └─controller
│ DemoController.java
│
└─resources
│ application.properties (配置文件)
│
└─static (存放静态资源)
index.html
关键文件内容详情如下,其余文件大多为空白文件。
2. POM 文件3. DemoController.java4.0.0 org.springframework.boot spring-boot-starter-parent 2.7.0 com.example demo 0.0.1-SNAPSHOT demo demo 11 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin 2.7.0
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class DemoController {
@RequestMapping("/index")
public String index() {
// 用于检测 RequestMapping 是否接收
System.out.println("This is index!");
// 记得添加后缀
return "index.html";
}
}
4. DemoApplication.java
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
- 文章系个人学习总结,希望可以给大家带来些许启发,欢迎提出建议或给予指正。
- 本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可。
- 欢迎大家转载分享,转载请标明源地址,谢谢



