springboot thymeleaf ----服务端渲染html
一、 引用命名空间 <html xmlns:th="http://www.thymeleaf.org"> 不这么写 html标签没闭合会报错
二、实际内容在../static//font-awesome/css/font-awesome.css
引入css
<link th:href="@{/font-awesome/css/font-awesome.css}" rel="stylesheet" />
引入js
<script type="text/javascript" th:src="@{/js/jquery-1.11.2.min.js}"></script>
三、输出内容
<p th:text="#{home.welcome}">Welcome to our grocery store!</p>
th:utext 用来显示“unescaped ” 的html内容
th:text="${today}" ${today} 用来引用 today 变量
四、
访问对象
${param.x} 返回名为x 的 request参数。(可能有多个值)
${session.x} 返回名为x的Session参数。
${application.x} 返回名为 servlet context 的参数。
五、
#{home.welcome(${session.user.name})} -- 格式化数据
#ctx: the context object.
#vars: the context variables.
#locale: the context locale.
#request: (only in Web Contexts) the HttpServletRequest object.
#response: (only in Web Contexts) the HttpServletResponse object.
#session: (only in Web Contexts) the HttpSession object.
#servletContext: (only in Web Contexts) the ServletContext object.
日期:
${#calendars.format(today,'dd MMMM yyyy')}
六、
星号语法
<div th:object="${session.user}">
<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>
七、
输出URL
<a href="product/list.html" th:href="@{/product/list}">Product List</a>
<a href="details.html" th:href="@{/order/{orderId}/details(orderId=${o.id})}">view</a>
八、
使用代码段
<div th:insert="~{commons :: main}">...</div>
<div th:if="${user.isAdmin()} == false"> --输出布尔表达式
<tr th:class="${user.id}? 'even' : 'odd'">
...
</tr>
九、
预处理
<p th:text="${__#{article.text('textVar')}__}">Some text here...</p>
设置任何Attribute 的方法
<input type="submit" value="Subscribe!" th:attr="value=#{subscribe.submit}"/> --设置单个
<img src="../../images/gtvglogo.png" th:attr="src=@{/images/gtvglogo.png},title=#{logo},alt=#{logo}" /> --一次设置多个
十、
循环
<tr th:each="prod : ${prods}">
<td th:text="${prod.name}">Onions</td>
<td th:text="${prod.price}">2.41</td>
<td th:text="${prod.inStock}? #{true} : #{false}">yes</td>
</tr>
springboot thymeleaf ----服务端渲染html的更多相关文章
- go, iris , nuxt, 服务端渲染等技术在helloworld开发者社区中的应用与实践
大家好,helloworld.net 上线已经有近半年的时间了,转眼过的好快,在这半年的时间里,迭代了近10多个版本,优化了很多的体验,交互上的不足之处,同时也上线了我们的安卓 app, 苹果的因为还 ...
- react+redux教程(六)redux服务端渲染流程
今天,我们要讲解的是react+redux服务端渲染.个人认为,react击败angular的真正“杀手锏”就是服务端渲染.我们为什么要实现服务端渲染,主要是为了SEO. 例子 例子仍然是官方的计数器 ...
- 使用 Vue 2.0 实现服务端渲染的 HackerNews
Vue 2.0 支持服务端渲染 (SSR),并且是流式的,可以做组件级的缓存,这使得极速渲染成为可能.同时, 和 2.0 也都能够配合 SSR 提供同构路由和客户端 state hydration.v ...
- React服务端渲染总结
欢迎吐槽 : ) 本demo地址( 前端库React+mobx+ReactRouter ):https://github.com/Penggggg/react-ssr.本文为笔者自学总结,有错误的地方 ...
- Diy页面服务端渲染解决方案
1. 问题由来 在移动互联网电商领域,运营每天需要搭建多个促销页面来吸引用户去点击去购买,一开始程序员临时写个新页面去实现,可这些页面可以用几次就不用了,每次创建新页面去实现费时费力,而且,电商的运营 ...
- react服务端渲染(同构)
学习react也有一段时间了,使用react后首页渲染的速度与seo一直不理想.打算研究一下react神奇服务端渲染. react服务端渲染只能使用nodejs做服务端语言实现前后端同构,在后台对re ...
- 如何使用Vue2做服务端渲染
花费了一个月时间,终于在新养车之家项目中成功部署了vue2服务端渲染(SSR),并且使用上了Vuex 负责状态管理,首屏加载时间从之前4G网络下的1000ms,提升到了现在500-700ms之间,SS ...
- 实例PK(Vue服务端渲染 VS Vue浏览器端渲染)
Vue 2.0 开始支持服务端渲染的功能,所以本文章也是基于vue 2.0以上版本.网上对于服务端渲染的资料还是比较少,最经典的莫过于Vue作者尤雨溪大神的 vue-hacker-news.本人在公司 ...
- Vue服务端渲染和Vue浏览器端渲染的性能对比
Vue 2.0 开始支持服务端渲染的功能,所以本文章也是基于vue 2.0以上版本.网上对于服务端渲染的资料还是比较少,最经典的莫过于Vue作者尤雨溪大神的 vue-hacker-news.本人在公司 ...
随机推荐
- 《DSP using MATLAB》Problem 8.45
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 在centos6.5 上安装最新版mysql
在mysql上如果直接安装mysql安装的不是5.6版本以上.下面记录怎么解决安装最新版mysql5.6以上. 1.查看本机都安装了mysql什么版本:rpm -qa | grep mysql,默认是 ...
- Interesting HDU - 5785 回文树
题意: 找出所有[i,j]为回文串[j+1,k]也为回文串的i*k乘积之和. 题解: 设sum1[i] 为正着插入,到 i 的所有回文串的起始位置的前缀和,sum2[i] 表示反正插入的前缀和 ans ...
- STM32 Keil仿真调试
引用:http://blog.sina.com.cn/s/blog_3c63d2bd0102vt9a.html 问题描述:使用MDK进行软件设计时没有使用ST官方的模板而是手动建立的工程,使用ST官方 ...
- vue项目使用history模式打包应该注意的地方
1.在config/index.js中将assetsPublicPath原来的’/‘修改为‘./’. build: { env: require('./prod.env'), index: path. ...
- 找到你的位置(JS在页面中的位置)最常用的方式是在页面中head部分放置<script>元素,浏览器解析head部分就会执行这个代码,然后才解析页面的其余部分
找到你的位置(JS在页面中的位置) 我们可以将JavaScript代码放在html文件中任何位置,但是我们一般放在网页的head或者body部分. 放在<head>部分 最常用的方式是在页 ...
- Task ProgressBar模拟现实完成后显示TextBox
private async void Form1_Load(object sender, EventArgs e) { progressBar1.Maximum = ; progressBar2.Ma ...
- ES5数组扩展
ES5给数组对象添加了一些方法, 常用的5个: 1. Array.prototype.indexOf(value) : 得到值在数组中的第一个下标 2. Array.prototype.lastInd ...
- leetcode-157周赛-5214-最长定差子序列
题目描述: class Solution: def longestSubsequence(self, arr: List[int], difference: int) -> int: dp = ...
- 几个 GetHashCode 函数
几个 GetHashCode 函数: DBTables.pas Delphi/Pascal code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...