学习内容
使用Thymeleaf编写一个HTML页面
访问静态资源
如何传递参数给HTML页面
模拟登录验证过程
构建项目
上一节已经说过如何构建一个SpringBoot项目,SpringBoot(一)Hello World 。由于本文采用了Thymeleaf模板引擎,因此需要添加Thymeleaf依赖,pom.xml如下所示
org.springframework.boot
spring-boot-starter-thymeleaf
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
编写HTML页面
新建LoginController,代码如下
package com.example.springbootchapter2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
* Created by lzc
* 2019/4/6 21:27
*/
@Controller
public class LoginController {
/**
* 登录页面
* @return
*/
@GetMapping("/login")
publ