当前位置:网站首页>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

边栏推荐
- What is multithreading
- 34-SparkSQL自定义函数的使用、SparkStreaming的架构及计算流程、DStream转换操作、SparkStreaming对接kafka和offset的处理
- Leetcode169-多数元素详解
- Leetcode shahutong series -- 63. Different paths II
- J9 number theory: what is Dao mode? Obstacles to the development of Dao
- Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK
- Unity—欧拉角,四元数
- 解决不挂载数据的页面刷新
- Sequence traversal II of leetcode107 binary tree
- Iterator pattern of behavioral pattern
猜你喜欢

The items of listview will be displayed completely after expansion

Old laptop becomes server (laptop + intranet penetration)

Getaverse,走向Web3的远方桥梁
34-SparkSQL自定义函数的使用、SparkStreaming的架构及计算流程、DStream转换操作、SparkStreaming对接kafka和offset的处理

最近随感,关于牛市和DeFi 2021-05-17

Leetcode200-查找岛屿数量详解

J9 number theory: what is Dao mode? Obstacles to the development of Dao

J9数字论:什么是DAO模式?DAO发展过程的阻碍

FreeRTOS个人笔记-互斥量

Appium中控件元素封装类梳理
随机推荐
Binary tree - 226. Flip binary tree
"Demons dance", is the bull market over? 2021-05-13
What does it mean that the web server stops responding?
栈的表示和实现(C语言)
Binary tree -- 104. Maximum depth of binary tree
Stm32 systeminit trap during simulation debugging
Iterator pattern of behavioral pattern
关于拼多多根据关键词取商品列表 API 的使用说明
@Autowired注解的底层原理
How to use yolov5 as an intelligent transportation system for red light running monitoring (1)
Js理解之路:写一个比较完美的组合继承(ES5)
Shib (firewood Dog Coin) rose hundreds of times in January. What core elements does a hundred times coin need? 2021-05-09
Exercise (2) create a set to store the elements "1", "$", "2", "$", "3", "$", "4"“
Kubernetes网络插件详解 - Calico篇 - 概述
Appium中控件元素封装类梳理
Weight file and pre training file of yolov3
MySQL——数据库日志
C language actual combat guessing game
二叉树相关知识
SHIB(柴犬币)一月涨幅数百倍,百倍币需具备哪些核心要素?2021-05-09