公司网站哪家做的好,协会建设网站的目的,建设网站需要做哪些工作内容,闵行网页设计师官网
https://www.thymeleaf.org/
介绍
Thymeleaf 是一个适用于 Web 和独立环境的现代服务器端 Java 模板引擎。 模板引擎#xff1a;为了使用户界面和业务数据分离而产生的#xff0c;它可以生成特定格式的文档#xff0c;用于网站的模板引擎会生成一个标准的 html 文档…官网
https://www.thymeleaf.org/
介绍
Thymeleaf 是一个适用于 Web 和独立环境的现代服务器端 Java 模板引擎。 模板引擎为了使用户界面和业务数据分离而产生的它可以生成特定格式的文档用于网站的模板引擎会生成一个标准的 html 文档。 模板的作用做好一个模板后套入对应的位置的数据最终以 html 的格式进行展示。 模板引擎的特点提高页面、代码的复用性。
官网文档
https://www.thymeleaf.org/doc/tutorials/3.1/thymeleafspring.html
依赖 pom.xml dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-thymeleaf/artifactId
/dependency配置
thymeleaf 的默认配置可以不改。 application.yml spring:application:name: systemthymeleaf:prefix: classpath:/templates/ #前缀默认为classpath:/templates/ suffix: .html #后缀默认为.html接口
在 controller 目录下新建 UserController 类。 此处返回的是 user 页面。 UserController.java package com.lm.system.controller;import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;/*** Author: DuHaoLin* Date: 2024/7/26*/
Controller
public class UserController {GetMapping(user)public String user(Model model) {model.addAttribute(name, Tom);model.addAttribute(age, 18);return user;}}
返回页面
在 resource 目录下新建 thymeleaf 默认获取的 templates 目录。 在 templates 目录下新建 user.html 文件。 user.html !DOCTYPE html
html langen xmlns:thhttp://www.thymeleaf.org
headmeta charsetUTF-8titleThymeleaf/title
/head
bodyspan姓名:/spanspan th:text${name}/spanbr /span年龄:/spanspan th:text${age}/span
/body
/html效果图展示
项目目录结构