博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springboot整合 Thymeleaf模板
阅读量:4569 次
发布时间:2019-06-08

本文共 1224 字,大约阅读时间需要 4 分钟。

首先引入maven jar依赖

org.springframework.boot
spring-boot-starter-thymeleaf
net.sourceforge.nekohtml
nekohtml
1.9.22

接着在application.properties内配置 thymeleaf

#设置thymeleaf  注意:一定要在web后面添加一个 斜杠 /,否则找不到文件spring.thymeleaf.prefix=classpath:/web/spring.thymeleaf.suffix=.html#设置thymeleaf不按照HTML5严格的检查标签spring.thymeleaf.mode=LEGACYHTML5

模板默认还是放在templates文件夹下,这里我修改到web文件夹下面了

package com.example.demo.controller;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import com.example.demo.entity.Student;@Controller@RequestMapping("/student/")public class StudentController {        @RequestMapping("show")    public String show(Model model) {                Student stu = new Student();        stu.setId(1001);        stu.setName("小明");        model.addAttribute("student", stu);                model.addAttribute("str", "this is spring boot freemarker");        return "show";    }}

 

Insert title here

thymeleaf

h3

id:
name:

 

转载于:https://www.cnblogs.com/blog411032/p/10339167.html

你可能感兴趣的文章
dict使用
查看>>
ASP.NET MVC的帮助类HtmlHelper和UrlHelper
查看>>
02_ListActive中响应事件 并LogCat输出
查看>>
doubleclick adx note
查看>>
Celery框架
查看>>
[c#]asp.net开发微信公众平台(4)关注事件、用户记录、回复文本消息
查看>>
[转载,感觉写的非常详细]DUBBO配置方式详解
查看>>
linux Valgrind使用说明-内存泄漏
查看>>
Android在Eclipse上的环境配置
查看>>
面向对象(五)
查看>>
android平台下使用点九PNG技术
查看>>
Python学习3,列表
查看>>
最长回文子串
查看>>
JAVA基础-JDBC(一)
查看>>
js中for和while运行速度比较
查看>>
算法第5章作业
查看>>
7.9 练习
查看>>
基于ArcGIS JS API的在线专题地图实现
查看>>
learnByWork
查看>>
lua 函数
查看>>