
Spring Boot 教程:Thymeleaf
发布日期:2021-05-14 00:52:26
浏览次数:24
分类:博客文章
本文共 5544 字,大约阅读时间需要 18 分钟。
������������������������
Thymeleaf ��������������� Java ��������������������������������������������������� web ������������������ web ������������ XHTML/HTML5 ������������������������������������������������������������ Thymeleaf ���������
Thymeleaf ������
Thymeleaf ��������������������������������������� XML ������������������������ 6 ���������������������
- XML
- ������ XML
- XHTML
- ������ XHTML
- HTML5
- ������ HTML5
������������ HTML5 ������������������������������������������ XML ��������������� HTML5 ��������������� web ������������ HTML5 ������������������������������������
Web ������
��������������� Thymeleaf ��������� Spring Boot ��������� web ������������������������������������
������������������������������ @Controller ��������������������������� URI ��� HTML ���������
1 package com.tutorialspoint.demo.controller; 2 3 import org.springframework.stereotype.Controller; 4 import org.springframework.web.bind.annotation.RequestMapping; 5 6 @Controller 7 public class WebController { 8 @RequestMapping(value = "/index") 9 public String index() {10 return "index";11 }12 }
��������������������������� URI ��� /index��������������������� index.html ������������������index.html ������������������ templates ������������������������ JS ��� CSS ������������������ classpath ������������ static ������������������������������������ CSS ������������������������
������������������������������������������������������������ CSS ��������������������� styles.css���
1 h4 {2 color: red;3 }
index.html ������������������������
1 2 3 4 5 6Spring Boot Application 7 8 9Welcome to Thymeleaf Spring Boot web application
10 11
���������������������������������������
������������������������������������������������������������ Spring Boot Starter Thymeleaf ���������
Maven ������������������������������������ pom.xml ���������
12 org.springframework.boot 3spring-boot-starter-thymeleaf 4
Gradle ��������������� build.gradle ������������������������������
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
��� Spring Boot ������������������������������
1 package com.tutorialspoint.demo; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.SpringBootApplication; 5 6 @SpringBootApplication 7 public class DemoApplication { 8 public static void main(String[] args) { 9 SpringApplication.run(DemoApplication.class, args);10 }11 }
Maven ��� pom.xml ���������������
1 26 7 4.0.0 8com.tutorialspoint 9demo 100.0.1-SNAPSHOT 11jar 12demo 13Demo project for Spring Boot 14 1516 21 22org.springframework.boot 17spring-boot-starter-parent 181.5.8.RELEASE 1920 23 27 28UTF-8 24UTF-8 251.8 2629 45 4630 33 34org.springframework.boot 31spring-boot-starter-web 3235 39 40org.springframework.boot 36spring-boot-starter-test 37test 3841 44org.springframework.boot 42spring-boot-starter-thymeleaf 4347 54 5548 5349 52org.springframework.boot 50spring-boot-maven-plugin 51
Gradle ��� build.gradle ���������������
1 buildscript { 2 ext { 3 springBootVersion = '1.5.8.RELEASE' 4 } 5 repositories { 6 mavenCentral() 7 } 8 dependencies { 9 classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")10 }11 }12 13 apply plugin: 'java'14 apply plugin: 'eclipse'15 apply plugin: 'org.springframework.boot'16 17 group = 'com.tutorialspoint'18 version = '0.0.1-SNAPSHOT'19 sourceCompatibility = 1.820 21 repositories {22 mavenCentral()23 }24 dependencies {25 compile('org.springframework.boot:spring-boot-starter-web')26 compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'27 testCompile('org.springframework.boot:spring-boot-starter-test')28 }
��������������������� Maven ��� Gradle ��������������������� executable JAR ��������������� Spring Boot ������������
Maven ���������������
mvn clean install
��� ���BUILD SUCCESS��� ��������������������� target ��������������� JAR ���������
Gradle ���������������������������
gradle clean build
��� ���BUILD SUCCESSFUL��� ��������������������� build/libs ��������������� JAR ���������
������������������������ JAR ���������
java ���jar
������������������ Tomcat 8080 ���������������������������������
��������������������������� URL������������������������������������������
发表评论
最新留言
路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月27日 04时39分51秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
ArrayList 实现类
2021-05-14
LinkedList 实现类
2021-05-14
Vector 实现类
2021-05-14
HashMap类、HashSet
2021-05-14
HashTable类
2021-05-14
TreeSet、TreeMap
2021-05-14
PrintStream
2021-05-14
ObjectInputStream、ObjectOutputStream
2021-05-14
读取properties文件信息
2021-05-14
线程生命周期
2021-05-14
JVM内存模型
2021-05-14
反射机制
2021-05-14
反射Field、Method、Constructor
2021-05-14
可变长度参数
2021-05-14
类加载器子系统
2021-05-14
堆空间常用参数总结
2021-05-14
逃逸分析-堆分配对象
2021-05-14
方法区“经典”内存结构
2021-05-14
常量池、运行时常量池
2021-05-14
GC算法
2021-05-14