当前位置:网站首页>Thymeleaf view integration
Thymeleaf view integration
2022-07-26 00:09:00 【Li Linnan】
Thymeleaf View integration
SpringBoot Support the integration of multiple view technologies , also SpringBoot It is recommended on the official website Thymeleaf As a front view page , Realize here Thymeleaf View integration , Introduce... With the help of an introductory project Thymeleaf Environment configuration .
starter Coordinates are introduced
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
add to Thymeleaf Configuration information
Thymeleaf Default view path resources/templates Catalog ( Automatic configuration class ThymeleafProperties Class decision ), This directory can be used in application.yml Modify in process .

## Environment selection configuration
spring:
# thymeleaf To configure
thymeleaf:
# Prefix ( The path of resource storage )
prefix: classpath:/html/
# close thymeleaf Page caching
cache: false
To write IndexController Controller forwarding view
@Controller
public class IndexController {
@RequestMapping("index")
public String index(Model model) {
// Set the value of the request field
model.addAttribute("msg", "Hello SpringBoot");
return "index";
}
}
html Add under directory index.html View
modify Thymeleaf The default storage path of the template ( stay resources Create under directory html Folder )
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Thymeleaf View </title></head>
<body>
<!-- Get the value of the request field -->
<h2 th:text="${msg}"></h2>
</body>
</html>
start-up Starter visit

边栏推荐
猜你喜欢

二叉树——222. 完全二叉树的节点个数

Binary tree - 404. Sum of left leaves

NVIDIA可编程推理加速器TensorRT学习笔记(三)——加速推理

Sequence traversal II of leetcode107 binary tree

SQLZOO——Nobel Quiz

二叉树——112. 路径总和

Shib (firewood Dog Coin) rose hundreds of times in January. What core elements does a hundred times coin need? 2021-05-09

URL address mapping configuration

复盘:推荐系统—— 负采样策略

Js理解之路:写一个比较完美的组合继承(ES5)
随机推荐
Sequence traversal II of leetcode107 binary tree
BGR and RGB convert each other
Binary tree 101. Symmetric binary tree
Niuke / Luogu - [noip2003 popularization group] stack
Sort fake contacts
MySQL的DDL、DML和DQL的基本语法
Binary tree -- 111. Minimum depth of binary tree
Shib (firewood Dog Coin) rose hundreds of times in January. What core elements does a hundred times coin need? 2021-05-09
Android solves the risk of database injection vulnerability
C language actual combat guessing game
链表相关方法
STM32 lighting procedure
用了MQ消息中间件后,我开始后悔了...
MySQL 索引使用有哪些注意事项呢?(从六个方面回答)
通货膨胀之下,后市如何操作?2021-05-14
appium 从启动到测试再到结束流程梳理
Leetcode169-多数元素详解
34-SparkSQL自定义函数的使用、SparkStreaming的架构及计算流程、DStream转换操作、SparkStreaming对接kafka和offset的处理
Pyqt5 rapid development and actual combat.pdf sharing
关于拼多多根据关键词取商品列表 API 的使用说明