Web模块:spring-boot-starter-web
spring-boot-autoconfigure-1.5.1.RELEASE.jar!/org/springframework/boot/autoconfigure/web
Spring Boot推荐使用Thymeleaf作为模板引擎,其提供了完美的Spring MVC支持、
内嵌Tomcat、Jetty无法执行jar形式的jsp;Undertow不支持JSP
- Thymeleaf页面基本样式
<!DOCTYPE html><html xmlns:th="http://www.thymeleaf.org"><head><meta charset="UTF-8"><title>首页</title><link th:href="@{bootstrap/css/bootstrap.min.css}" rel="stylesheet"/><link th:href="@{bootstrap/css/bootstrap-theme.min.css}" rel="stylesheet"/><script th:src="@{jquery-1.10.2.min.js}" type="text/javascript"></script><script th:src="@{bootstrap/js/bootstrap.min.js}"></script></head><body>Hello World</body></html>
- 访问model中元素属性
<div class="panel panel-primary"><div class="panel-heading"><h3 class="panel-title">访问model</h3></div><div class="panel-body"><span th:text="${singlePerson.name}"></span></div></div>
- 迭代元素
- <ul class="list-group">
<li class="list-group-item" th:each="person:${people}"><span th:text="${person.name}"></span><span th:text="${person.age}"></span><button class="btn" th:onclick="'getName(\'' + ${person.name} + '\');'">获得名字</button></li></ul>
- 空判断
<div th:if="${not #lists.isEmpty(people)}"></div>
- JavaScript中访问model中元素
<script th:inline="javascript">var single = [[${singlePerson}]];console.log(single.name+"/"+single.age)function getName(name){console.log(name);}</script>
- Thymeleaf与Spring MVC集成
pom
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>测试页面</title>
<link th:href="@{bootstrap/css/bootstrap.min.css}" rel="stylesheet"/>
<link th:href="@{bootstrap/css/bootstrap-theme.min.css}" rel="stylesheet"/>
<script th:src="@{jquery-1.10.2.min.js}" type="text/javascript"></script>
<script th:src="@{bootstrap/js/bootstrap.min.js}"></script> </head>
<body>
Hello World<br/> <div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">访问model</h3>
</div>
<div class="panel-body">
<!--/*@thymesVar id="singlePerson" type=""*/-->
<span th:text="${singlePerson.name}"></span>
</div>
</div> <div th:if="${not #lists.isEmpty(people)}">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">列表</h3>
</div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item" th:each="person:${people}">
<span th:text="${person.name}"></span>
<span th:text="${person.age}"></span>
<button class="btn" th:onclick="'getName(\'' + ${person.name} + '\');'">获得名字</button>
</li>
</ul>
</div>
</div>
</div> <script th:inline="javascript">
var single = [[${singlePerson}]];
console.log(single.name + "/" + single.age); function getName(name) {
console.log(name);
}
</script> </body>
</html>
Web模块:spring-boot-starter-web的更多相关文章
- Spring Boot 嵌入式Web容器
目录 前言 1.起源 2.容器启动流程解析 2.1.获取应用类型 2.2.容器启动流程 3.加载 Web 容器工厂 4.总结 前言 最近在学习Spring Boot相关的课程,过程中以 ...
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
上篇博客使用Spring Boot开发Web项目我们简单介绍了使用如何使用Spring Boot创建一个使用了Thymeleaf模板引擎的Web项目,当然这还远远不够.今天我们再来看看如何给我们的We ...
- Spring Boot:Web 综合开发
Web 开发 Spring Boot Web 开发非常的简单,其中包括常用的 json 输出.filters.property.log 等 json 接口开发 在以前使用 Spring 开发项目,需要 ...
- 【spring boot】5.spring boot 创建web项目并使用jsp作前台页面
贼烦的是,使用spring boot 创建web项目,然后我再idea下创建的,but 仅仅启动spring boot的启动类,就算整个项目都是好着的,就算是能够进入controller中,也不能成功 ...
- 通过docker-composer启动容器nginx,并完成spring.boot的web站点端口转发
前面已经讲过2篇基于docker的mysql.redis容器编排并启动.这次将练习下nginx的docker方式的部署,以及通过nginx去代理宿主主机上的Web服务应该怎么配 PS:(这里由于ngi ...
- Spring Boot 2.X(四):Spring Boot 自定义 Web MVC 配置
0.准备 Spring Boot 不仅提供了相当简单使用的自动配置功能,而且开放了非常自由灵活的配置类.Spring MVC 为我们提供了 WebMvcConfigurationSupport 类和一 ...
- Spring Boot开发Web应用之Thymeleaf篇
前言 Web开发是我们平时开发中至关重要的,这里就来介绍一下Spring Boot对Web开发的支持. 正文 Spring Boot提供了spring-boot-starter-web为Web开发予以 ...
- Spring Boot Starter 介绍
http://www.baeldung.com/spring-boot-starters 作者:baeldung 译者:http://oopsguy.com 1.概述 依赖管理是任何复杂项目的关键部分 ...
- spring -boot s-tarter 详解
Starter POMs是可以包含到应用中的一个方便的依赖关系描述符集合.你可以获取所有Spring及相关技术的一站式服务,而不需要翻阅示例代码,拷贝粘贴大量的依赖描述符.例如,如果你想使用Sprin ...
- SpringBoot 之Spring Boot Starter依赖包及作用
Spring Boot 之Spring Boot Starter依赖包及作用 spring-boot-starter 这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. spri ...
随机推荐
- 20155315 2016-2017-2 《Java程序设计》第二周学习总结
教材学习内容总结 在教材中,有一句话叫做 伪代码是最好的注释. 一开始我不理解什么是伪代码,但在参考了百度和C语言的学习过程后,我发现伪代码的作用就相当于是解决问题前期的流程图设计,伪代码设计好了之后 ...
- Storyboarding by Scripting
Storyboarding by Scripting In the .osu file, under [Events]:Note: underscores can be replaced with s ...
- win10 64位redis的安装和测试
步骤记录: 1.官网没有redis64位的版本,在git开源项目上找到64位的可用版本 https://www.cnblogs.com/tommy-huang/p/6093813.html 这里有下载 ...
- [BZOJ1565][NOI2009]植物大战僵尸-[网络流-最小割+最大点权闭合子图+拓扑排序]
Description 传送门 Solution em本题知识点是用网络流求最大点权闭合子图. 闭合图定义:图中任何一个点u,若有边u->v,则v必定也在图中. 建图:运用最小割思想,将S向点权 ...
- RHSCA模拟考试
开始考试:桌面是个黑框子 点击reboot按钮,破解密码 开机成功,输入startx进入图形界面 不能复制,要在物理机用ssh root@172.25.0.11 远程连接,就可以复制粘贴了 * Hos ...
- Luogu3804 【模板】后缀自动机
题面 题解 一个串的出现次数等于$endpos$的大小,也是$parent$树上节点的$size$大小, 构建出后缀自动机,按拓补序,模拟即可. 代码 #include<cstdio> # ...
- PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
只要有人用了: select t.* from 表名 t where 字段=xxx for update 而不是: select t.rowid,t.* from 表名 t where 字段=x ...
- jenkins+jacoco+ant自动化代码和应用服务代码分离场景获取远程服务的覆盖率
前提 自动化代码和应用服务代码分离.jenkins和tomcat服务器分离 思想 1.在tomcat启动javaagent监听. 2.运用其他job_B已部署的应用服务代码 3.拉取自动化代码,开始测 ...
- MySQL数据库--连接
MySQL数据库的概念: MySQL数据库,包括客户端和服务端.客户端就是操作数据库的终端(命令行.navicat),服务端就是安装有MySQL软件的主机(本机或者服务器),MySQL数据库的端口一般 ...
- flexbox的应用
2009年,display: box 就已经出现,但是直到IE11的发布,全部的主流浏览器才统一支持新的用法display: flex. 这里只说应用,浏览器的兼容处理会附在文章的末尾. 起步 在现代 ...