iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >如何使用Spring Boot thymeleaf模板引擎
  • 729
分享到

如何使用Spring Boot thymeleaf模板引擎

2023-06-07 22:06:10 729人浏览 薄情痞子
摘要

本篇内容主要讲解“如何使用Spring Boot thymeleaf模板引擎”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何使用spring Boot thymeleaf模板引擎”吧!在早期开

本篇内容主要讲解“如何使用Spring Boot thymeleaf模板引擎”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何使用spring Boot thymeleaf模板引擎”吧!

在早期开发的时候,我们完成的都是静态页面也就是html页面,随着时间轴的发展,慢慢的引入了jsp页面,当在后端服务查询到数据之后可以转发到jsp页面,可以轻松的使用jsp页面来实现数据的显示及交互,jsp有非常强大的功能,但是,在使用SpringBoot的时候,整个项目是以jar包的方式运行而不是war包,而且还嵌入了Tomcat容器,因此,在默认情况下是不支持jsp页面的。如果直接以纯静态页面的方式会给我们的开发带来很大的麻烦,springboot推荐使用模板引擎。

模板引擎有很多种,jsp,freemarker,thymeleaf,模板引擎的作用就是我们来写一个页面模板,比如有些值呢,是动态的,我们写一些表达式。而这些值,从哪来呢,我们来组装一些数据,我们把这些数据找到。然后把这个模板和这个数据交给我们模板引擎,模板引擎按照我们这个数据帮你把这表达式解析、填充到我们指定的位置,然后把这个数据最终生成一个我们想要的内容给我们写出去,这就是我们这个模板引擎,不管是jsp还是其他模板引擎,都是这个思想。只不过不同的模板引擎语法不同而已,下面重点学习下springboot推荐使用的thymeleaf模板引擎,语法简单且功能强大

1、thymeleaf的介绍

导入依赖:

 <!--thymeleaf模板-->  <dependency>   <groupId>org.thymeleaf</groupId>   <artifactId>thymeleaf-spring5</artifactId>  </dependency>  <dependency>   <groupId>org.thymeleaf.extras</groupId>   <artifactId>thymeleaf-extras-java8time</artifactId>  </dependency>

在springboot中有专门的thymeleaf配置类:ThymeleafProperties

@ConfigurationProperties(prefix = "spring.thymeleaf")public class ThymeleafProperties {private static final Charset DEFAULT_ENcoding = StandardCharsets.UTF_8;public static final String DEFAULT_PREFIX = "classpath:/templates/";public static final String DEFAULT_SUFFIX = ".html";private boolean checkTemplate = true;private boolean checkTemplateLocation = true;private String prefix = DEFAULT_PREFIX;private String suffix = DEFAULT_SUFFIX;private String mode = "HTML";private Charset encoding = DEFAULT_ENCODING;private boolean cache = true;

2、thymeleaf使用模板

在java代码中写入如下代码:

@RequestMapping("/hello") public String hello(Model model){  model.addAttribute("msg","Hello");  //classpath:/templates/hello.html  return "hello"; }

html页面中写入如下代码:

<!DOCTYPE html><html lang="en" xmlns:th="Http://www.thymeleaf.org"><body><h2>Hello</h2><div th:text="${msg}"></div></body></html>

3、thymeleaf的表达式语法

Simple expressions:Variable Expressions: ${...}Selection Variable Expressions: *{...}Message Expressions: #{...}Link URL Expressions: @{...}Fragment Expressions: ~{...}LiteralsText literals: 'one text', 'Another one!',…Number literals: 0, 34, 3.0, 12.3,…Boolean literals: true, falseNull literal: nullLiteral tokens: one, sometext, main,…Text operations:String concatenation: +Literal substitutions: |The name is ${name}|Arithmetic operations:Binary operators: +, -, *, /, %Minus sign (unary operator): -Boolean operations:Binary operators: and, orBoolean negation (unary operator): !, notComparisons and equality:Comparators: >, <, >=, <= (gt, lt, ge, le)Equality operators: ==, != (eq, ne)Conditional operators:If-then: (if) ? (then)If-then-else: (if) ? (then) : (else)Default: (value) ?: (defaultvalue)Special tokens:No-Operation: _

4、thymeleaf实例演示

th的常用属性值

一、th:text :设置当前元素的文本内容,相同功能的还有th:utext,两者的区别在于前者不会转义html标签,后者会。优先级不高:order=7

二、th:value:设置当前元素的value值,类似修改指定属性的还有th:src,th:href。优先级不高:order=6

三、th:each:遍历循环元素,和th:text或th:value一起使用。注意该属性修饰的标签位置,详细往后看。优先级很高:order=2

四、th:if:条件判断,类似的还有th:unless,th:switch,th:case。优先级较高:order=3

五、th:insert:代码块引入,类似的还有th:replace,th:include,三者的区别较大,若使用不恰当会破坏html结构,常用于公共代码块提取的场景。优先级最高:order=1

六、th:fragment:定义代码块,方便被th:insert引用。优先级最低:order=8

七、th:object:声明变量,一般和*{}一起配合使用,达到偷懒的效果。优先级一般:order=4

八、th:attr:修改任意属性,实际开发中用的较少,因为有丰富的其他th属性帮忙,类似的还有th:attrappend,th:attrprepend。优先级一般:order=5

thymeleaf.html

<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"> <title>Title</title></head><body> <p th:text="${thText}"></p> <p th:utext="${thUText}"></p> <input type="text" th:value="${thValue}"> <div th:each="message:${thEach}">  <p th:text="${message}"></p> </div> <div>  <p th:text="${message}" th:each="message:${thEach}"></p> </div> <p th:text="${thIf}" th:if="${not #strings.isEmpty(thIf)}"></p> <div th:object="${thObject}">  <p>name:<span th:text="*{name}"/></p>  <p>age:<span th:text="*{age}"/></p>  <p>gender:<span th:text="*{gender}"/></p> </div></body></html>

ThymeleafController.java

import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.WEB.bind.annotation.RequestMapping;@Controllerpublic class ThymeleafController { @RequestMapping("thymeleaf") public String thymeleaf(ModelMap map){  map.put("thText","th:text设置文本内容 <b>加粗</b>");  map.put("thUText","th:utext 设置文本内容 <b>加粗</b>");  map.put("thValue","thValue 设置当前元素的value值");  map.put("thEach","Arrays.asList(\"th:each\", \"遍历列表\")");  map.put("thIf","msg is not null");  map.put("thObject",new Person("zhangsan",12,"男"));  return "thymeleaf"; }}

标准表达式语法

${...} 变量表达式,Variable Expressions

*{...} 选择变量表达式,Selection Variable Expressions

一、可以获取对象的属性和方法

二、可以使用ctx,vars,locale,request,response,session,servletContext内置对象

session.setAttribute("user","zhangsan");th:text="${session.user}"

三、可以使用dates,numbers,strings,objects,arrays,lists,sets,maps等内置方法

standardExpression.html

<!--一、strings:字符串格式化方法,常用的Java方法它都有。比如:equals,equalsIgnoreCase,length,trim,toUpperCase,toLowerCase,indexOf,substring,replace,startsWith,endsWith,contains,containsIgnoreCase等二、numbers:数值格式化方法,常用的方法有:fORMatDecimal等三、bools:布尔方法,常用的方法有:isTrue,isFalse等四、arrays:数组方法,常用的方法有:toArray,length,isEmpty,contains,containsAll等五、lists,sets:集合方法,常用的方法有:toList,size,isEmpty,contains,containsAll,sort等六、maps:对象方法,常用的方法有:size,isEmpty,containsKey,containsValue等七、dates:日期方法,常用的方法有:format,year,month,hour,createNow等--><!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"> <title>thymeleaf内置方法</title></head><body> <h4>#strings </h4> <div th:if="${not #strings.isEmpty(Str)}" >  <p>Old Str : <span th:text="${Str}"/></p>  <p>toUpperCase : <span th:text="${#strings.toUpperCase(Str)}"/></p>  <p>toLowerCase : <span th:text="${#strings.toLowerCase(Str)}"/></p>  <p>equals : <span th:text="${#strings.equals(Str, 'blog')}"/></p>  <p>equalsIgnoreCase : <span th:text="${#strings.equalsIgnoreCase(Str, 'blog')}"/></p>  <p>indexOf : <span th:text="${#strings.indexOf(Str, 'r')}"/></p>  <p>substring : <span th:text="${#strings.substring(Str, 2, 4)}"/></p>  <p>replace : <span th:text="${#strings.replace(Str, 'it', 'IT')}"/></p>  <p>startsWith : <span th:text="${#strings.startsWith(Str, 'it')}"/></p>  <p>contains : <span th:text="${#strings.contains(Str, 'IT')}"/></p> </div> <h4>#numbers </h4> <div>  <p>formatDecimal 整数部分随意,小数点后保留两位,四舍五入: <span th:text="${#numbers.formatDecimal(Num, 0, 2)}"/></p>  <p>formatDecimal 整数部分保留五位数,小数点后保留两位,四舍五入: <span th:text="${#numbers.formatDecimal(Num, 5, 2)}"/></p> </div> <h4>#bools </h4> <div th:if="${#bools.isTrue(Bool)}">  <p th:text="${Bool}"></p> </div> <h4>#arrays </h4> <div th:if="${not #arrays.isEmpty(Array)}">  <p>length : <span th:text="${#arrays.length(Array)}"/></p>  <p>contains : <span th:text="${#arrays.contains(Array,2)}"/></p>  <p>containsAll : <span th:text="${#arrays.containsAll(Array, Array)}"/></p> </div> <h4>#lists </h4> <div th:if="${not #lists.isEmpty(List)}">  <p>size : <span th:text="${#lists.size(List)}"/></p>  <p>contains : <span th:text="${#lists.contains(List, 0)}"/></p>  <p>sort : <span th:text="${#lists.sort(List)}"/></p> </div> <h4>#maps </h4> <div th:if="${not #maps.isEmpty(HashMap)}">  <p>size : <span th:text="${#maps.size(hashMap)}"/></p>  <p>containsKey : <span th:text="${#maps.containsKey(hashMap, 'thName')}"/></p>  <p>containsValue : <span th:text="${#maps.containsValue(hashMap, '#maps')}"/></p> </div> <h4>#dates </h4> <div>  <p>format : <span th:text="${#dates.format(Date)}"/></p>  <p>custom format : <span th:text="${#dates.format(Date, 'yyyy-MM-dd HH:mm:ss')}"/></p>  <p>day : <span th:text="${#dates.day(Date)}"/></p>  <p>month : <span th:text="${#dates.month(Date)}"/></p>  <p>monthName : <span th:text="${#dates.monthName(Date)}"/></p>  <p>year : <span th:text="${#dates.year(Date)}"/></p>  <p>dayOfWeekName : <span th:text="${#dates.dayOfWeekName(Date)}"/></p>  <p>hour : <span th:text="${#dates.hour(Date)}"/></p>  <p>minute : <span th:text="${#dates.minute(Date)}"/></p>  <p>second : <span th:text="${#dates.second(Date)}"/></p>  <p>createNow : <span th:text="${#dates.createNow()}"/></p> </div></body></html>

ThymeleafController.java

@RequestMapping("standardExpression") public String standardExpression(ModelMap map){  map.put("Str", "Blog");  map.put("Bool", true);  map.put("Array", new Integer[]{1,2,3,4});  map.put("List", Arrays.asList(1,3,2,4,0));  Map hashMap = new HashMap();  hashMap.put("thName", "${#...}");  hashMap.put("desc", "变量表达式内置方法");  map.put("Map", hashMap);  map.put("Date", new Date());  map.put("Num", 888.888D);  return "standardExpression"; }

@{...} 链接表达式,Link URL Expressions

<!--不管是静态资源的引用,form表单的请求,凡是链接都可以用@{...} 。这样可以动态获取项目路径,即便项目名变了,依然可以正常访问链接表达式结构无参:@{/xxx}有参:@{/xxx(k1=v1,k2=v2)} 对应url结构:xxx?k1=v1&k2=v2引入本地资源:@{/项目本地的资源路径}引入外部资源:@{/webjars/资源在jar包中的路径}--><link th:href="@{/webjars/bootstrap/4.0.0/CSS/bootstrap.css}" rel="external nofollow" rel="stylesheet"><link th:href="@{/main/css/123.css}" rel="external nofollow" rel="stylesheet"><form class="form-login" th:action="@{/user/login}" th:method="post" ><a class="btn btn-sm" th:href="@{/login.html(l='zh_CN')}" rel="external nofollow" >中文</a><a class="btn btn-sm" th:href="@{/login.html(l='en_US')}" rel="external nofollow" >English</a>

#{...} 消息表达式,Message Expressions

<!-- 消息表达式一般用于国际化的场景。结构:th:text="#{msg}"-->

~{...} 代码块表达式,Fragment Expressions

fragment.html

<!--支持两种语法结构推荐:~{templatename::fragmentname}支持:~{templatename::#id}templatename:模版名,Thymeleaf会根据模版名解析完整路:/resources/templates/templatename.html,要注意文件的路径。fragmentname:片段名,Thymeleaf通过th:fragment声明定义代码块,即:th:fragment="fragmentname"id:HTML的id选择器,使用时要在前面加上#号,不支持class选择器。代码块表达式的使用代码块表达式需要配合th属性(th:insert,th:replace,th:include)一起使用。th:insert:将代码块片段整个插入到使用了th:insert的HTML标签中,th:replace:将代码块片段整个替换使用了th:replace的HTML标签中,th:include:将代码块片段包含的内容插入到使用了th:include的HTML标签中,--><!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"> <title>Title</title></head><body><!--th:fragment定义代码块标识--><footer th:fragment="copy"> 2019 The Good Thymes Virtual Grocery</footer><!--三种不同的引入方式--><div th:insert="fragment::copy"></div><div th:replace="fragment::copy"></div><div th:include="fragment::copy"></div><!--th:insert是在div中插入代码块,即多了一层div--><div> <footer>  &copy; 2011 The Good Thymes Virtual Grocery </footer></div><!--th:replace是将代码块代替当前div,其html结构和之前一致--><footer> &copy; 2011 The Good Thymes Virtual Grocery</footer><!--th:include是将代码块footer的内容插入到div中,即少了一层footer--><div> &copy; 2011 The Good Thymes Virtual Grocery</div></body></html>

5、国际化的配置

在很多应用场景下,我们需要实现页面的国际化,springboot对国际化有很好的支持, 下面来演示对应的效果。

idea中设置统一的编码格式,file->settings->Editors->File Encoding,选择编码格式为utf-8

在resources资源文件下创建一个i8n的目录,创建一个login.properties的文件,还有login_zh_CN.properties,idea会自动识别国际化操作

创建三个不同的文件,名称分别是:login.properties,login_en_US.properties,login_zh_CN.properties

内容如下:

#login.propertieslogin.passWord=密码1login.remmber=记住我1login.sign=登录1login.username=用户名1#login_en_US.propertieslogin.password=Passwordlogin.remmber=Remember Melogin.sign=Sign Inlogin.username=Username#login_zh_CN.propertieslogin.password=密码~login.remmber=记住我~login.sign=登录~login.username=用户名~

配置国际化的资源路径

spring: messages: basename: i18n/login

编写html页面

初始html页面<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"> <head>  <meta charset="UTF-8"/>  <title>Title</title> </head> <body>  <form action="" method="post">   <label >Username</label>   <input type="text" name="username" placeholder="Username" >   <label >Password</label>   <input type="password" name="password" placeholder="Password" >   <br> <br>   <div>    <label>     <input type="checkbox" value="remember-me"/> Remember Me    </label>   </div>   <br>   <button type="submit">Sign in</button>   <br> <br>   <a>中文</a>   <a>English</a>  </form> </body></html>修改后的页面<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"> <head>  <meta charset="UTF-8"/>  <title>Title</title> </head> <body>  <form action="" method="post">   <label th:text="#{login.username}">Username</label>   <input type="text" name="username" placeholder="Username" th:placeholder="#{login.username}">   <label th:text="#{login.password}">Password</label>   <input type="password" name="password" placeholder="Password" th:placeholder="#{login.password}">   <br> <br>   <div>    <label>     <input type="checkbox" value="remember-me"/> [[#{login.remmber}]]    </label>   </div>   <br>   <button type="submit" th:text="#{login.sign}">Sign in</button>   <br> <br>   <a>中文</a>   <a>English</a>  </form> </body></html>

可以看到通过浏览器的切换语言已经能够实现,想要通过超链接实现的话,如下所示:

添加WebmvcConfig.java代码

import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.util.StringUtils;import org.springframework.web.servlet.LocaleResolver;import org.springframework.web.servlet.config.annotation.ViewControllerReGIStry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;import javax.servlet.http.httpservletRequest;import javax.servlet.http.HttpServletResponse;import java.util.Locale;@Configurationpublic class WebMVCConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) {  registry.addViewController("/").setViewName("login");  registry.addViewController("/login.html").setViewName("login"); } @Bean public LocaleResolver localeResolver(){  return new NativeLocaleResolver(); } protected static class NativeLocaleResolver implements LocaleResolver{  @Override  public Locale resolveLocale(HttpServletRequest request) {   String language = request.getParameter("language");   Locale locale = Locale.getDefault();   if(!StringUtils.isEmpty(language)){    String[] split = language.split("_");    locale = new Locale(split[0],split[1]);   }   return locale;  }  @Override  public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {  } }}

login.html页面修改为:

<!DOCTYPE html><html lang="en" xmlns:th="http://www.thymeleaf.org"><head> <meta charset="UTF-8"/> <title>Title</title></head><body><form action="" method="post"> <label th:text="#{login.username}">Username</label> <input type="text" name="username" placeholder="Username" th:placeholder="#{login.username}"> <label th:text="#{login.password}">Password</label> <input type="password" name="password" placeholder="Password" th:placeholder="#{login.password}"> <br> <br> <div>  <label>   <input type="checkbox" value="remember-me"/> [[#{login.remmber}]]  </label> </div> <br> <button type="submit" th:text="#{login.sign}">Sign in</button> <br> <br> <a th:href="@{/login.html(language='zh_CN')}" rel="external nofollow" >中文</a> <a th:href="@{/login.html(language='en_US')}" rel="external nofollow" >English</a></form></body></html>

国际化的源码解释:

//MessageSourceAutoConfiguration public class MessageSourceAutoConfiguration { private static final Resource[] NO_RESOURCES = new Resource[0]; public MessageSourceAutoConfiguration() { } @Bean @ConfigurationProperties(prefix = "spring.messages") //我们的配置文件可以直接放在类路径下叫: messages.properties, 就可以进行国际化操作了 public MessageSourceProperties messageSourceProperties() {  return new MessageSourceProperties(); } @Bean public MessageSource messageSource(MessageSourceProperties properties) {  ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();  if (StringUtils.hasText(properties.getBasename())) {        //设置国际化文件的基础名(去掉语言国家代码的)   messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));  }  if (properties.getEncoding() != null) {   messageSource.setDefaultEncoding(properties.getEncoding().name());  }  messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());  Duration cacheDuration = properties.getCacheDuration();  if (cacheDuration != null) {   messageSource.setCacheMillis(cacheDuration.toMillis());  }  messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());  messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());  return messageSource; }}//WebMvcAutoConfiguration@Bean@ConditionalOnMissingBean@ConditionalOnProperty(prefix = "spring.mvc", name = "locale")public LocaleResolver localeResolver() {if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {return new FixedLocaleResolver(this.mvcProperties.getLocale());}AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();localeResolver.setDefaultLocale(this.mvcProperties.getLocale());return localeResolver;}//AcceptHeaderLocaleResolver@Overridepublic Locale resolveLocale(HttpServletRequest request) {Locale defaultLocale = getDefaultLocale();if (defaultLocale != null && request.getHeader("Accept-Language") == null) {return defaultLocale;}Locale requestLocale = request.getLocale();List<Locale> supportedLocales = getSupportedLocales();if (supportedLocales.isEmpty() || supportedLocales.contains(requestLocale)) {return requestLocale;}Locale supportedLocale = findSupportedLocale(request, supportedLocales);if (supportedLocale != null) {return supportedLocale;}return (defaultLocale != null ? defaultLocale : requestLocale);}

到此,相信大家对“如何使用Spring Boot thymeleaf模板引擎”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

--结束END--

本文标题: 如何使用Spring Boot thymeleaf模板引擎

本文链接: https://www.lsjlt.com/news/250399.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 如何使用Spring Boot thymeleaf模板引擎
    本篇内容主要讲解“如何使用Spring Boot thymeleaf模板引擎”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何使用Spring Boot thymeleaf模板引擎”吧!在早期开...
    99+
    2023-06-07
  • spring Boot怎么与Thymeleaf模板引擎结合使用
    这篇文章给大家介绍spring Boot怎么与Thymeleaf模板引擎结合使用,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。Thymeleaf:Thymeleaf是一个java类库,他是一个xml/xhtml/htm...
    99+
    2023-05-31
    springboot thymeleaf
  • thymeleaf模板如何在spring boot中使用
    这篇文章将为大家详细讲解有关thymeleaf模板如何在spring boot中使用,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。前言Thymeleaf 是一个跟 Velocity、Free...
    99+
    2023-05-31
    springboot thymeleaf
  • Thymeleaf模板引擎怎么使用
    今天小编给大家分享一下Thymeleaf模板引擎怎么使用的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来...
    99+
    2022-10-19
  • 解读thymeleaf模板引擎中th:if的使用
    目录thymeleaf模板引擎中th:if的使用th:if 条件判断th:if 判断表达式Thymeleaf模板引擎语法使用1、模板引擎thymeleaf使用2、ognl表达式的语法...
    99+
    2022-11-13
    thymeleaf模板引擎 th:if的使用 thymeleaf模板
  • SpringBoot自带模板引擎Thymeleaf使用详解②
    目录 一、条件判断和迭代遍历 1.1 条件判断 2.2 迭代遍历 二、获取域中的数据和URL写法 2.1 获取域中的数据 2.2 URL写法 三、相关配置 一、条件判断和迭代遍历 1.1 条件判断 语法 作用 th:if 条件判断 准...
    99+
    2023-10-21
    spring boot 后端 java thymeleaf 原力计划
  • 如何使用Spring Boot+Thymeleaf
    本篇内容主要讲解“如何使用Spring Boot+Thymeleaf”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何使用Spring Boot+Thymeleaf”吧!1. Thymeleaf...
    99+
    2023-06-15
  • Spring boot如何搭建web应用集成thymeleaf模板实现登陆
    这篇文章将为大家详细讲解有关Spring boot如何搭建web应用集成thymeleaf模板实现登陆,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。Spring boot 搭建web应用集成了thymel...
    99+
    2023-05-30
    springboot web thymeleaf
  • Nodejs中怎么使用模板引擎以及使用模板引擎渲染HTML
    这篇文章给大家分享的是有关Nodejs中怎么使用模板引擎以及使用模板引擎渲染HTML的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。使用readdir获取指定路径下的所有文件名文件...
    99+
    2022-10-19
  • SpringBoot中如何使用Thymeleaf模板
    本文小编为大家详细介绍“SpringBoot中如何使用Thymeleaf模板”,内容详细,步骤清晰,细节处理妥当,希望这篇“SpringBoot中如何使用Thymeleaf模板”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习...
    99+
    2023-06-30
  • 如何在PHP中使用模板引擎?
    随着网站的不断发展,许多开发人员开始使用模板引擎来更方便地管理和呈现网站内容。PHP作为一种非常流行的网站开发语言,也提供了许多模板引擎供开发者选择,例如Smarty、Twig和Blade等。在本篇文章中,我们将介绍如何在PHP中使用模板引...
    99+
    2023-05-14
    使用 PHP 模板引擎
  • Thinkphp 6 使用thinkTemplate 模板引擎
    使用thinkTemplate 模板引擎 由于Thinkphp 5.1 之前的版本 已经将Think-view 拓展 集成到 vendor 中 Tp6 将大部分转为拓展使用 新版框架默认只能支持PHP...
    99+
    2023-09-03
    php 开发语言
  • C#中Razor模板引擎简单使用
    目录引用使用Razor模板引擎语法1、简介:2、原理:3、语法规则:使用视图引擎可以完成一些需要定制化内容格式的问题,比如邮件模板。 引用 install-package Razor...
    99+
    2022-11-13
  • flask中模板引擎的使用方法
    小编给大家分享一下flask中模板引擎的使用方法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!在我们对flask的一些引擎使用时,就不得不提到其中的一个默认引擎了...
    99+
    2023-06-14
  • C#中Razor模板引擎怎么使用
    这篇文章主要讲解了“C#中Razor模板引擎怎么使用”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“C#中Razor模板引擎怎么使用”吧!使用视图引擎可以完成一些需要定制化内容格式的问题,比如...
    99+
    2023-06-29
  • Spring Boot + Mybatis + Spring MVC环境配置(五):templates模板使用
    Spring Boot中,静态资源(css、js、图片等)默认放在resources/static下面。如果要修改默认存放目录,可以通过设置属性 spring.mvc.static-path-pattern来实现。模板文件默认放在...
    99+
    2023-06-02
  • Springboot中如何整合thymleaf模板引擎
    本篇内容介绍了“Springboot中如何整合thymleaf模板引擎”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!1. thymeleaf...
    99+
    2023-06-08
  • Spring Boot整合Elasticsearch如何实现全文搜索引擎
    这篇文章给大家分享的是有关Spring Boot整合Elasticsearch如何实现全文搜索引擎的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。简单说,ElasticSearch(简称 ES)是搜索引擎,是结构化...
    99+
    2023-05-30
    spring boot elasticsearch
  • 如何进行Web中前后端模板引擎的使用
    这期内容当中小编将会给大家带来有关如何进行Web中前后端模板引擎的使用,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。前言这篇文章本来不打算写的,实话说楼主对前端模板的认识...
    99+
    2022-10-19
  • 如何基于SSM集成Freemarker模板引擎
    这篇文章主要为大家展示了“如何基于SSM集成Freemarker模板引擎”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何基于SSM集成Freemarker模板引擎”这篇文章吧。FreeMark...
    99+
    2023-06-28
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作