自学SpringBoot五之Thymeleaf模板

Spring Boot 2.x整合模版引擎(1)-Thymeleaf的XML模式,自定义方言属性 背景 前段时间有一需求,需要动态修改xml模版的内容,但是网上能收集的资料多是关于thymeleaf的HTML使用方式;于是,在【科学上网】与自己的研究下,终于成功解决了这个需求。 通过下文,将可以学到Spring Boot2.x+Thymeleaf的XML模式的使用,以及自定义Thymeleaf方言属性两个知识点;水平有限,若有误,欢迎各路英雄指正。 一、Thymeleaf的XML模... 阅读详情

一,什么是Thymeleaf?

  • Thymeleaf是Java的一个模板引擎,能够处理html,xml,JavaScript,css甚至纯文本。类似于jsp,Freemarker。
  • Thymeleaf是一种自然模板,原型即页面。
  • Thymeleaf语法优雅易懂,支持OGNL、SpringEL表达式。可以用于存储对象的属性,调用对象的方法。
  • Thymeleaf遵从Web标准,支持html5。
  • Thymeleaf的官网:https://www.thymeleaf.org/
  • 中文文档下载地址:https://download.youkuaiyun.com/download/ai_ting_java/10732544

二、Thymeleaf的引入

1.需要在html引用的命名空间

<html xmlns:th="http://www.thymeleaf.org">

2.在maven项目中的pom文件的依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

三、Thymeleaf的简单使用

首先Thymeleaf的内置的视图解析器是将html的文件默认放在classpath:/templates/*下的,并添加尾缀--html。

controller的代码:

package com.yangli.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: admin
 * Date: 2018-10-21
 * Time: 22:25
 */
@Controller
public class ThymeleafController {

    @RequestMapping("/getsucess")
    public String getSucess(){
        //classpath:/templates/sucess.html
        return "sucess";
    }
}

简单的sucess.html页面:

<!DOCTYPE html>
<!--引入命名空间-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>getScuess</h1>
    姓名:<span th:text="${name}">此处显示姓名</span>
</body>
</html>

页面效果:

四、Thymeleaf的规则和语法

1.<p th:text="...">XXX</p>: th:text="..."是改变标签的文本内容或者属性的。

注:th:语法格式可以替换任意的html原生属性的值;eg:

controller的部分代码:

html的代码:

按下浏览器的F12可以查看到<span>标签的id和class值到底是什么:

很明显在<span>标签中我们最开始定义的值都被th:id="${id}" th:class="${class}"替换掉了。

简单表达式语法:

  • 变量表达式:$ {...}:实际上是在上下⽂中包含的变量的映射上执⾏的OGNL表达式对象。OGNL表达式具有强大的功能,以后会专门写一篇关于OGNL表达式的文章。
  • 选择变量表达式:* {...}:我们不仅可以将变量表达式写为$ {...},还可以作为* {...}。这两种⽅式有⼀个重要的区别:星号语法计算所选对象⽽不是整个上下⽂的表达式。 也就是说,只要没有选定的对象,$和*语法就会完全相同。
    什么是选定对象? 常配合使⽤th:object属性的表达式的结果,即此时的*号就代表这个object对象。如下例所示:
<div th:object="${session.user}">
  //此时下面的<p>标签中th:text的取值就是直接从session.user对象中取出来的,*号就表示usr对象
 <p>Name: <span th:text="*{firstName}">Sebastian</span>.</p>    
 <p>Surname: <span th:text="*{lastName}">Pepper</span>.</p>    
 <p>Nationality: <span th:text="*{nationality}">Saturn</span>.</p>  
</div>

以上的代码完全等同于:

<div>
    <p>Name: <span th:text="${session.user.firstName}">Sebastian</span>.</p>
    <p>Surname: <span th:text="${session.user.lastName}">Pepper</span>.</p>
    <p>Nationality: <span th:text="${session.user.nationality}">Saturn</span>.</p>
</div>

 

  • 消息表达式:#{...}:获取国际化内容
  • 链接⽹址表达式:@ {...}:定义URL;
<!-- 以前的写法 'http://localhost:8080/gtvg/order/details?orderId=3' (plus rewriting) -->
<!-- 绝对URL路径 使用Thymeleaf时的写法以及传参的形式(orderId=${o.id})-->
<a href="details.html"
th:href="@{http://localhost:8080/gtvg/order/details(orderId=${o.id})}">view</a>
<!-- 以前的写法 '/gtvg/order/details?orderId=3' (plus re4.4 URL链接59writing) -->
<!-- 当前项目下的相对URL路径 使用Thymeleaf时的写法以及传参的形式(orderId=${o.id})-->
<a href="details.html" th:href="@{/order/details(orderId=${o.id})}">view</a>
<!-- 以前的写法和传参 '/gtvg/order/3/details' (plus rewriting)-->
<a href="details.html" th:href="@{/order/{orderId}/details(orderId=${o.id})}">view</a>

注意:
th:href是⼀个修饰符属性:⼀旦处理,它将计算要使⽤的链接URL,并将该值设置为<a>标签的href属性。我们被允许使⽤表达式的URL参数(可以在orderId = $ {o.id}中看到)。所需的URL参数编码操作也将⾃动执⾏。如果需要⼏个参数,这些参数将以逗号分隔:@ {/ order /process(execId = $ {execId},execType ='FAST')}。

URL路径中也允许使⽤变量模板:@ {/ order /{orderId} /details(orderId = $ {orderId})}。以/开头的相对URL(例如:/ order / details)将⾃动以应⽤程序上下⽂名称为前缀。如果cookie未启⽤或尚未知道,则可能会在相对URL中添加“;jsessionid = ...”后缀,以便会话被保留。这被称为URL重写,Thymeleaf允许您使⽤Servlet API中的每个URL的response.encodeURL(...)机制来插⼊⾃⼰的重写过滤器。th:href属性允许我们(可选地)在我们的模板中有⼀个⼯作的静态href属性,这样当我们直接打开原型设计时,我们的模板链接可以被浏览器导航。与消息语法(#{...})的情况⼀样,URL基数也可以是计算另⼀个表达式的结果:

<a th:href="@{${url}(orderId=${o.id})}">view</a>
  • ⽚段表达式:〜{...}:片段引用表达式;代码⽚段表达式是表示标记⽚段的简单⽅法,并将其移动到模板周围。这允许我们复制它们,将它们传递给其他模板作为参数,等等。最常⻅的⽤法是使⽤th:insert或th:replace进⾏⽚段插⼊。
<div th:insert="~{commons :: main}">...</div>
<!-- 它们可以在任何地⽅使⽤,就像任何其他变量⼀样 -->
<div th:with="frag=~{footer :: #main/text()}">
<p th:insert="${frag}">
</div>

五、属性优先级

我们期望th:each属性在th:text之前执⾏,以便得到我们想要的结果,但是鉴于HTML / XML标准对于某个属性的渲染顺序没有任何定义, 因此ThymeLeaf如果要达到这种效果,必须在属性本身中建⽴优先机制,以确保这些属性按预期⼯作。

优先级由上至下依次递减

未完待续~~~~

layuimini后台模板+Springboot整合Thymeleaf layuimini后台模板+Springboot整合Thymeleaf 首先下载layuimini模板: 代码仓库(iframe 多tab版) v2版:- 在线预览地址:http://layuimini.99php.cn/iframe/v2/index.html - GitHub仓库地址:https://github.com/zhongshaofa/layuimini/tree/v2 - Gitee仓库地址:https://gitee.com/zhongshaofa/layuimini/tree/. 阅读详情

相关推荐

【SpringBoot】3、SpringBoot中整合Thymeleaf模板引擎

SpringBoot 为我们提供了 Thymeleaf 自动化配置解决方案,所以我们在 SpringBoot 中使用 Thymeleaf 非常方便 一、简介 Thymeleaf是一个流行的模板引擎,该模板引擎采用Java语言开发,模板引擎是一个技术名词,是跨领域跨平台的概念,在Java语言体系下有模板引擎,在C#、PHP语言体系下也有模板引擎。除了thymeleaf之外还有Velocity、Fr...

JACKAL 21万+

Thymeleaf 是一款用于渲染 XML/XHTML/HTML5 内容的模板引擎

Thymeleaf 是一款用于渲染 XML/XHTML/HTML5 内容的模板引擎。它与 JSP,Velocity,FreeMaker 等模板引擎类似,也可以轻易地与 Spring MVC 等 Web 框架集成。与其它模板引擎相比,Thymeleaf 最大的特点是,即使不启动 Web 应用,也可以直接在浏览器中打开并正确显示模板页面 。

ITSM/ITIL/网络安全/IT运维 1621

springboot中使用thymeleaf模板

springboot中使用thymeleaf模板的步骤。 (1) 使用thymeleaf模板 步骤一:添加thymeleaf依赖。 依赖代码: <!-- thymeleaf依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifac...

✅ Java 开发工程师 2563

《IDEA工具》最新版 2021.1 添加thymeleaf视图模板,添加mapper.xml视图模板,快速开发超级详细教程

我们在开发的过程中,可能需要新建许多HTML页面,或者XML等等。 重复的配置往往会消耗掉太多时间,添加视图层模板,可以节省我们开发的时间,方便后期编程开发工作。如:thymeleaf,以及mapper.xml等等. 这里我就以新建thymeleaf模板为例子。 1.首先我们来看下图,在没有新建模板之前,我们在NEW中,是看不见什么自定义添加的模板的。 2.要添加新模板,要依次点击 file>Settings。 3.接着在弹出的窗口中输入 “File and Code Templates”,搜索

weixin_42868605的博客 4020

映泰TB250-BTC主板魔改BIOS支持8/9代CPU实战与开机故障排查

BIOS(基本输入输出系统)是计算机硬件与操作系统之间的桥梁,负责初始化硬件和提供运行时服务。其工作原理是通过存储在主板芯片中的固件程序,在上电自检(POST)阶段完成对CPU、内存等关键组件的检测与配置。魔改BIOS的技术价值在于突破硬件限制,通过修改微码和电源管理模块,让旧平台支持新处理器,从而以极低成本实现性能跃升,在预算有限或追求极致性价比的DIY、办公和软路由等应用场景中极具吸引力。本文以映泰TB250-BTC矿板为例,详细解析了通过软刷方式刷入魔改BIOS,并重点解决了刷写后常见的“开机风扇转一

weixin_29164185的博客 417

西门子RS485自由口通信Modbus RTU 通信协议

部分西门子的RS485模块不能使用西门子自带的Modbus RTU通信指令,需要通过自己拼接、发送、接收和解析报文完成Modbus RTU通信。通过多次尝试完成该功能: #R_TRIG_Instance(CLK := #触发, Q => #触发上升沿); IF #触发上升沿 THEN // 触发后先将读取完成复位 #读写完成 := 0; END_IF; CASE #功能码 OF 1: // 线圈状态读取 ; 2:

qq_20792765的博客 1万+

Vue computed 实现

建立与其他属性(如:data、 Store)的联系; 属性改变后,通知计算属性重新计算 实现时,主要如下 初始化 data, 使用 Object.defineProperty 把这些属性全部转为 getter/setter。 初始化 computed, 遍历 computed 里的每个属性,每个 computed 属性都是一个 watch 实例。每个属性提供的函数作为属性的 getter,使用 Object.defineProperty 转化。 Object.defineProperty gett.

LuckXinXin的博客 245

RC滤波电路实战解析:无源与有源设计的性能对比与应用选择

本文深入解析了RC滤波电路的核心原理,重点对比了无源滤波电路与有源滤波电路的性能差异。文章通过实测波形与仿真数据,详细阐述了两者在带载能力、频率响应精度、噪声特性等方面的优劣,并提供了清晰的应用选择指南,帮助工程师根据信号属性、负载条件和性能要求做出最优设计决策。

weixin_29268637的博客 431

Thymeleaf模板引擎

工号姓名生日是否已婚工资

刻苦的樊同学 445

AIDC储能技术:AI数据中心的高效能源解决方案

储能技术作为现代数据中心的核心支撑系统,通过电化学能量存储与释放实现电力供需平衡。其核心原理在于利用电池管理系统(BMS)实现毫秒级响应,配合光伏等可再生能源构成光储融合系统。在AI算力爆发的背景下,AIDC储能系统展现出三大技术价值:应对脉冲式电力需求、保障供电连续性、提升绿色能源占比。典型应用场景包括大模型训练中心、超算设施等对电力质量要求苛刻的环境。当前行业聚焦10C超高倍率电芯和直流侧耦合架构等创新方案,其中磷酸铁锂电池凭借三维极耳设计和液冷系统等技术突破,成为AIDC储能的主流选择。

weixin_29189377的博客 118

Python爬虫应对Cloudflare防护:5秒盾+Turnstile验证码实战(AST反混淆+指纹模拟,成功率95%)

Cloudflare 5秒盾+Turnstile验证码的防护核心,是通过“前端JS挑战+多维度指纹校验”确认请求来源的真实性。用AST反混淆还原CF的验证逻辑,避免执行无用代码导致的验证失败;基于真实浏览器采集指纹,确保指纹维度100%匹配真人环境;结合轻量级JS引擎和自动化工具,模拟完整的浏览器执行环境。该方案的绕过成功率可达95%(剩余5%主要是IP或请求频率导致的风控),适用于绝大多数部署CF防护的网站。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1718

【SpringBoot】| Thymeleaf 模板引擎

【SpringBoot】| Thymeleaf 模板引擎

m0_61933976的博客 6856

【ARXML专题】-2-创建一个Classic CAN(经典CAN2.0)/CANFD的系统描述ARXML文件

目录 1 创建一个AUTOSAR系统描述 2 物理层命名以及创建ECU 3 新建一个Frame 4 新建一个PDU 5 新建一个signal 6 结尾 AUTOSAR System Description Network Explorer是一个文件编辑器,支持可视化和编辑系统描述的AUTOSAR系统描述文件和ECU摘录的通信内容,它支持架构版本4.0.3、4.1.2、4.2.1、4.2.2和4.3.0。AUTOSAR系统描述(ARXML)文件是基于XML的文件格式,描述网络通信的元素...

「汽车电子助手」的博客 1万+

SpringBoot系列——Thymeleaf模板

  前言   thymeleaf是springboot官方推荐使用的java模板引擎,在springboot的参考指南里的第28.1.10Template Engines中介绍并推荐使用thymeleaf,建议我们应该避免使用jsp,jsp的本质是一个java的servlet类,jsp引擎将jsp的内容编译成.class,"out.write"输出到response再响应到浏览器,虽然java是一次编译,到处运行,但也大大增加了服务器压力,而且jsp将后台java语言嵌入页面,还要放入服务容器才能打...

ITSM/ITIL/网络安全/IT运维 4743

手把手教你学RDMA驱动开发专栏--第7章 队列对(QP)与数据传输实现​7.3 完成队列(CQ):事件通知机制与轮询/中断模式

本章详细探讨了RDMA驱动中完成队列(CQ)的事件通知机制,重点分析了轮询与中断两种模式的实现原理及优化策略。CQ作为操作结果的报告载体,其核心功能包括结果反馈、事件通知和资源同步。轮询模式通过主动查询实现低延迟,适合高性能场景;中断模式通过被动通知节省CPU资源,适用于低频事件处理。驱动实现需考虑CQ溢出防护、多QP共享同步等关键问题,并提供事件通道机制将CQE传递给用户态。通过对比两种模式的优缺点及适用场景,揭示了RDMA系统在性能与资源间的权衡机制。

MHD0815的博客 397

【100分- 求最多可以派出多少支团队】(题目+思路+Java&C++&Python解析+在线测试)

用数组代表每个人的能力,一个比赛活动要求参赛团队的最低能力值为N,每个团队可以由1人或者2人组成,且1个人只能参加1个团队,计算出最多可以派出多少只符合要求的团队。

m0_73659489的博客 314

【Springboot】SpringBoot基础知识及整合Thymeleaf模板引擎

①Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。一、

未来可以改变 2115

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SpringBoot 之Thymeleaf模板

对于面试,一定要有良好的心态,这位小伙伴面试美团的时候没有被前面阿里的面试影响到,发挥也很正常,也就能顺利拿下美团的offer。小编还整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家,也祝愿大家都能够升职加薪!《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!图片转存中…(img-UMKV9VwL-1712680280469)]也祝愿大家都能够升职加薪!

2401_84046545的博客 1234

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

SpringBoot-web开发(三): 模板引擎Thymeleaf

目录1. 引入2. 什么是模板引擎?3. Thymeleaf1. 简介2. 导入Thymeleaf3. 使用Thymeleaf4. 简单测试5. thymeleaf语法1、th属性2、标准表达式语法 本文主要介绍SpringBoot给我们推荐的Thymeleaf模板引擎,这是一个高级语言的模板引擎,语法更简单且功能更强大 参考:https://www.jianshu.com/p/7c27c50f24ec 1. 引入 在以前,我们通常将前端交给我们的html页面转成jsp页面,通过jsp轻松实现数据.

欢迎来到 Baret-H 的博客 8475

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

【❤️SpringBoot模板引擎❤️】——Thymeleaf

目录 模板引擎简介 引入Thymeleaf模板引擎 分析Thymeleaf模板引擎 测试Thymeleaf模板引擎 Thymeleaf入门: thymeleaf语法学习 练习测试 总结: 模板引擎简介 jsp有着强大的功能,能查出一些数据转发到JSP页面以后,我们可以用jsp轻松实现数据的显示及交互等,包括能写Java代码。但是,SpringBoot首先是以jar的方式,不是war;其次我们的tomcat是嵌入式的,所以现在默认不支持jsp。 如果我们直接用纯静态页面方式,必然会...

龍弟-idea的博客 6308

SpringBoot之Thymeleaf模板使用

SpringBoot之Thymeleaf模板使用 介绍 开发传统Java WEB工程时,我们可以使用JSP页面模板语言,但是在SpringBoot中已经不推荐使用了。SpringBoot支持如下页面模板语言 Thymeleaf FreeMarker Velocity Groovy JSP 上面并没有列举所有SpringBoot支持的页面模板技术。其中Thymeleaf是SpringBoot官方所推荐使用的,下面来谈谈Thymeleaf一些常用的语法规则。 Thymeleaf默认的页面文件后缀是.html 为

weixin_45203607的博客 3955

springboot thymeleaf模板解析错误

## 求解!!!springboot中thymeleaf模板解析错误org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8081-exec-1] Exception processing template "upload": An error happened during template parsing (template: "class ...

weixin_43869132的博客 4943

SpringBoot整合Thymeleaf模板

前言 Thymeleaf 是一个优秀的、面向Java 的XML庆HTML/HTML5 页面模板,具有丰富的标签语言和函数。因此,在使用Spring Boot 框架进行页面设计时, 一般都会选择Thymeleaf 模板。对Thymeleaf模板不太熟悉的可以访问:Thymeleaf模板的使用 SpringBoot整合Thymeleaf搭建Web项目 新建springboot项目 选择spri...

小马同学 7957

SpringBoot 集成 Jsp、Thymeleaf 模板引擎 + Thymeleaf 基本使用

2020年在匆匆忙忙慌慌乱乱中就这么度过了,我们迎来了新一年,互联网的发展如此之快,技术日新月异,更新迭代成为了这个时代的代名词,坚持下来的技术体系会越来越健壮,JVM作为如今是跳槽大厂必备的技能,如果你还没掌握,更别提之后更新的新技术了。更多JVM面试整理:《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》点击传送门,即可获取!

2401_84091502的博客 1191

SpringBoot构建Web应用,整合Thymeleaf模板

创建springboot web 工程 在官网上 创建springboot工程(在idea中创建)

Jonathan的博客 5735
上一篇: 自学SpringBoot四之日志管理
下一篇: inner join,left join,right join
Ai_Ying_Java
博客等级 码龄9年 30粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值