-
org.springframework.boot -
spring-boot-starter-thymeleaf -

这里注意:下面任意一项不对都会运行异常
2、因为是通过地址栏访问,所以使用@GetMapping注解,注解后的内容可随意写,访问时的地址就是:“http://localhost:8080/自己写的GetMapping后的内容”
3、return“ ”里面填的字符串一定要是自己放入templates里的html页面的名字。
-
- @Controller
- public class LoginController {
-
- // 跳转登录页面
- @GetMapping("/index")
- public String login () {
- // response.sendRedirect("index");
- // response.sendRedirect("index.html");
- // return "../resources/templates/index.html";
-
- return "index";
- }