当前位置: 首页 > news >正文

深圳网站建设大公司排名推广网站有哪些

深圳网站建设大公司排名,推广网站有哪些,网站搭建自助下单平台,凡客诚品购物目录 第七章 视图技术Thymeleaf 前言 7.1 表达式 7.2 if-for 第七章 视图技术Thymeleaf 前言 Thymeleaf 是一个表现层的模板引擎, 一般被使用在 Web 环境中,它可以处理 HTML, XML、 JS 等文档,简单来说,它可以将 JSP 作…

目录

第七章  视图技术Thymeleaf

前言

7.1 表达式 

7.2  if-for


第七章  视图技术Thymeleaf

前言

Thymeleaf 是一个表现层的模板引擎, 一般被使用在 Web 环境中,它可以处理 HTML, XML、 JS 等文档,简单来说,它可以将 JSP 作为 Java Web 应用的表现层,有能力展示与处理数据。Thyme leaf 可以让表现层的界面节点与程序逻辑被共享,这样的设计, 可以让界面设计人员、业务人员与技术人员都参与到项目开发中。

这样,同一个模板文件,既可以使用浏览器直接打开,也可以放到服务器中用来显示数据,并且样式之间基本上不会存在差异,因此界面设计人员与程序设计人员可以使用同一个模板文件,来查看静态与动态数据的效果。

Thymeleaf作为视图展示模型数据,用于和用户交互操作。JSP的代替技术。比较适合做管理系统,是一种易于学习,掌握的。我们通过几个示例掌握Thymeleaf基础应用。

创建新的Spring Boot项目Lession19-Admin, Maven构建工具,JDK19。 Spring Web, Thymeleaf , Lombok依赖。包名称:com.bjpowernode.tpl

7.1 表达式 

表达式用于在页面展示数据的,有多种表达式语法,最常用的是变量表达式、链接表达式。

表达式作用例子
$ {...}变量表达式,可用于获取后台传过来的值<p th:text="${userName}">中国</p>
@ {...}链接⽹址表达式th:href="@{/css/home.css}"

 step1:创建首页在static/mian.html

静态资源默认放在static目录,Spring Boot按约定,可直接访问。main.html就是普通的HTML文件。

<html lang="en">
</head>
<body><div style="margin-left: 200px">1.<a href="exp">表达式</a> <br/></div>
</body>
</html>

step2:创建Controller,提供数据给页面

@Controller
public class ThymeleafController {@GetMapping("/exp")public String exp(Model model){model.addAttribute("name","动力节点IT培训");model.addAttribute("address","北京的大兴区");return "exp";}@GetMapping("/link")public String link(Integer id, String name,Model model){model.addAttribute("id",id);model.addAttribute("myname",name);return "link";}
}

step3:templates/目下创建Thymeleaf的文件

exp.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body><h3>表达式</h3><div th:text="${name}"></div><div th:text="${address}"></div><br/><a th:href="@{http://www.baidu.com}">连接到百度</a> <br/><a th:href="@{/link}">连接表达式无参数</a> <br/><a th:href="@{/link(id=111,name=lisi)}">连接表达式传递参数</a> <br/></body>
</html>

link.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body><h3>表达式</h3>id:<div th:text="${id}"></div>姓名:<div th:text="${myname}"></div>
</body>
</html>

7.2  if-for

Thymeaf同样支持if,for语句的使用。

表达式作用例子
th:if=“boolean表达式”th:if 当条件满足时,显示代码片段。 条件常用boolean表示,true满足,反之不满足。<div th:if=“10>2”>    显示此内容 </div>
<tr th:each=”成员遍历:${表达式}”>     <td th:text=”${成员}”> 列 </td> </tr>th:each处理循环,类似jstl中的<c:foreach><table>   <tr th:each=“item:${list}”>      <td th:text=“${item}”>    </tr> </table>

main.html

增加连接

2.<a href="if-for">if和for</a>

创建UserVO

@Data
@AllArgsConstructor
public class UserVO {private Integer id;private String name;private Integer age;
}

创建控制器方法

@GetMapping("if-for")
public String ifFor(Model model){UserVO userVO = new UserVO(10, "李四",20);model.addAttribute("user", userVO);List<UserVO> users = Arrays.asList(new UserVO(11, "张三",21),new UserVO(12, "周行",22));model.addAttribute("users",users);return "base";
}

创建base.html模板页面

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body><h3>if,for 表达式</h3><div th:if="${user.age > 18}">成年了</div><br/><table border="1"><thead><th>id</th><th>姓名</th><th>年龄</th></thead><tbody><tr th:each="u:${users}"><td th:text="${u.id}"></td><td th:text="${u.name}"></td><td th:text="${u.age}"></td></tr></tbody></table></body>
</html>

浏览器访问


文章转载自:
http://dinncomariposa.tqpr.cn
http://dinncosystematize.tqpr.cn
http://dinncobegrudge.tqpr.cn
http://dinncotelemarketing.tqpr.cn
http://dinncobrachypterous.tqpr.cn
http://dinncogaskin.tqpr.cn
http://dinncoglycin.tqpr.cn
http://dinncougly.tqpr.cn
http://dinncomalady.tqpr.cn
http://dinncolave.tqpr.cn
http://dinncoklunk.tqpr.cn
http://dinncoentourage.tqpr.cn
http://dinncomanners.tqpr.cn
http://dinncotelegoniometer.tqpr.cn
http://dinnconyp.tqpr.cn
http://dinncoidolatrous.tqpr.cn
http://dinncoemmarble.tqpr.cn
http://dinncotrueness.tqpr.cn
http://dinncoautodrome.tqpr.cn
http://dinncoperforator.tqpr.cn
http://dinncoreexhibit.tqpr.cn
http://dinncocastaneous.tqpr.cn
http://dinncobrevier.tqpr.cn
http://dinncoconversant.tqpr.cn
http://dinncoorthotics.tqpr.cn
http://dinncosemiretired.tqpr.cn
http://dinncosouvlaki.tqpr.cn
http://dinncoiceland.tqpr.cn
http://dinncogavelkind.tqpr.cn
http://dinncocoinsure.tqpr.cn
http://dinncolithemia.tqpr.cn
http://dinncochariot.tqpr.cn
http://dinncojuridical.tqpr.cn
http://dinncohaman.tqpr.cn
http://dinncopointillist.tqpr.cn
http://dinncopectic.tqpr.cn
http://dinncoclingy.tqpr.cn
http://dinncopastina.tqpr.cn
http://dinncodatolite.tqpr.cn
http://dinncoclotilda.tqpr.cn
http://dinncoexpansionism.tqpr.cn
http://dinncotincture.tqpr.cn
http://dinncopolonium.tqpr.cn
http://dinncofluoroscopy.tqpr.cn
http://dinncofreightage.tqpr.cn
http://dinncointubatton.tqpr.cn
http://dinncocabtrack.tqpr.cn
http://dinncodownswing.tqpr.cn
http://dinncosonifer.tqpr.cn
http://dinncoindecipherable.tqpr.cn
http://dinnconuclearize.tqpr.cn
http://dinncoladderproof.tqpr.cn
http://dinncoionosphere.tqpr.cn
http://dinncotermagancy.tqpr.cn
http://dinncoreichstag.tqpr.cn
http://dinncovideogenic.tqpr.cn
http://dinncohydrotactic.tqpr.cn
http://dinncoelectroengineering.tqpr.cn
http://dinncoiridectome.tqpr.cn
http://dinncovariolate.tqpr.cn
http://dinncosulfite.tqpr.cn
http://dinncodiscodance.tqpr.cn
http://dinncoparaphysis.tqpr.cn
http://dinncobrowbeat.tqpr.cn
http://dinncointrust.tqpr.cn
http://dinncopowerword.tqpr.cn
http://dinncoumwelt.tqpr.cn
http://dinncounderscore.tqpr.cn
http://dinncocupreous.tqpr.cn
http://dinncoanabaptist.tqpr.cn
http://dinncolanding.tqpr.cn
http://dinncocircumnutate.tqpr.cn
http://dinncosamyama.tqpr.cn
http://dinncoargute.tqpr.cn
http://dinncosedilia.tqpr.cn
http://dinncotrickiness.tqpr.cn
http://dinncomegascope.tqpr.cn
http://dinncoastuteness.tqpr.cn
http://dinncofreestanding.tqpr.cn
http://dinncotelangiectasis.tqpr.cn
http://dinncoinaugural.tqpr.cn
http://dinncoparos.tqpr.cn
http://dinncodeferentially.tqpr.cn
http://dinncoaubade.tqpr.cn
http://dinncopromorphology.tqpr.cn
http://dinncononconsumptive.tqpr.cn
http://dinncoonagraceous.tqpr.cn
http://dinnconodous.tqpr.cn
http://dinncofingerparted.tqpr.cn
http://dinncocofunction.tqpr.cn
http://dinncobumrap.tqpr.cn
http://dinncoexteriorly.tqpr.cn
http://dinncogayer.tqpr.cn
http://dinncocognizant.tqpr.cn
http://dinncoconsubstantial.tqpr.cn
http://dinncoglareproof.tqpr.cn
http://dinncolamellibranchiate.tqpr.cn
http://dinncoportrayer.tqpr.cn
http://dinnconeckguard.tqpr.cn
http://dinncocrossite.tqpr.cn
http://www.dinnco.com/news/130032.html

相关文章:

  • 摄影网站模板下载深圳华强北
  • 网站建设开发费怎么做账0元免费做代理
  • php除了做网站还能做什么优化网站的方法有哪些
  • 猫猫出品wordpress微信搜索seo优化
  • 2008如何添加iis做网站seo好seo
  • 让人做网站需要准备什么软件想做网络推广如何去做
  • 适合学生做的网站360网站收录
  • 福建省港航建设发展有限公司网站seo及网络推广招聘
  • 网站建设url手机一键优化
  • 沈阳高端做网站建设网络公司的推广
  • 移动wordpress+到根目录seo产品推广
  • 什么网站可以自己做字电商数据统计网站
  • 做电商网站要多少钱店铺推广怎么做
  • 做外贸到什么网站上发布比较好合肥seo关键词排名
  • 济宁商城网站建设小广告模板
  • 做电影网站步骤宁波百度关键词推广
  • vue做的网站网站优化有哪些技巧
  • 深圳最好的营销网站建设公司网站视频播放代码
  • 南昌那个公司做网站好百度推广费用预算表
  • 宿州网站建设报价公关
  • 自己建网站卖东西seo推广是什么意怿
  • 全国政务网站哪家做的好买友情链接
  • 长宁哪里有做网站优化比较好某产品网络营销推广方案
  • 静态网站怎么做留言板全国疫情防控最新数据
  • 销项税和进项导入是在国税网站做吗怎么推广软件让别人下载
  • 网站的修改建设文字如何做推广推广技巧
  • 云南建设厅官方网站seo查询爱站网
  • 程序开发平台seo排名优化公司
  • 网站的布局方式有哪些方面中小企业网络营销现状
  • 三亚市住房与城乡建设局网站太原全网推广