首先我们创建一个spring Initializr项目
然后输入项目组,和项目名称
选择一下项目的jar包
其次我们需要这些测试类和测试html
我们需要在这里调用一下index.html
这里是代码
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexController {
@RequestMapping("/")
public String index(){
return “index.html”;
}
}
application.properties配置文件,只要配置一下访问端口就好了
然后我们再打开网页输入http://localhost:8080/就可以访问了