1、前端页面
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>function</title>
</head>
<body>
<h1>功能表达式对象</h1>
<div th:text="${time}"></div>
<div th:text="${#dates.format(time, 'yyyy-MM-dd HH:mm:ss')}"></div>
<br><br>
<div th:text="${data}"></div>
<div th:text="${#strings.substring(data, 0, 13)}"></div>
</body>
</html>
2、后台控制器
package com.springboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Date;
/**
* @author dc
* @date 2020/5/22 - 17:40
*/
@Controller
public class MyController {
@RequestMapping("/first")
public String doFirst(Model model){
model.addAttribute("data", "hello, springboot");
model.addAttribute("time", new Date());
return "function";
}
}