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 ...
随机推荐
- 实现Linux下dc的功能,计算后缀表达式的值
提交测试截图和码云练习项目链接,实现Linux下dc的功能,计算后缀表达式的值 -将运算符写在两个操作数之后的表达式称为"后缀表达式",如上面的中缀表达式可转换为后缀表达式1 2 ...
- 20155332 2016-2017-2 《Java程序设计》第10周学习总结
20155332 2016-2017-2 <Java程序设计>第10周学习总结 教材学习内容总结 了解计算机网络基础 掌握Java Socket编程 理解混合密码系统 掌握Java 密码技 ...
- 20155338 2016-2017-2《Java程序设计》第1周学习总结
20155338 2016-2017-2<Java程序设计>第1周学习总结 了解成绩构成 成绩构成:100分=翻转课堂考核12次(512 = 60)+ 实验5次(3 5 =15)+ 团队项 ...
- 自己在UWP程序上调用usb转串口的路程
之前一直是在普通的framework环境下写串口,使用的类为 SerialPort 这个类大家可能比较熟悉.但是在UWP的开发里,使用的是 SerialDevice 这个类,是不一样的. 1. 清单文 ...
- 关于js回调方法 js递归时使用方法
js中递归调用本身可以这样: function a1(n){ a1(n)}但是如果需要在参数n进行自增的情况下判断会出错: function a1(n){ if(n>10) return 'aa ...
- 《C++设计新思维》勘误,附C++14新解法
勘误: 原书(中文版)3.13节,65-69页中GenScatterHierarchy以及FieldHelper均存在问题,当TypeList中类型有重复时,无法通过编译(原因在于“二义性基类”). ...
- python-生成器、迭代器、装饰器
目录 动态语言和静态语言 __slots__ 生成器 迭代器 闭包 装饰器 动态语言和静态语言 动态语言可以在运行的过程中修改代码,例如python在运行的过程中给已创建好的类添加属性和方法. 静态语 ...
- webpack整体配置结构
摘自<深入浅出webpack>2.8 const path = require('path'); module.exports = { // entry 表示入口,webpack执行的第一 ...
- JavaScript学习笔记(三)——对象
第四章 理解对象 1 说明 对象的状态:属性,行为:方法: 对象定义放在花括号内: 用冒号分隔属性名和属性值: 用逗号分隔属性名和属性值对,包括方法: 最后一个属性值后面不加逗号: 属性名可以是任何字 ...
- 关于Amazon.com Seller 网络以及IP地址更换 官方回答
Greetings from Amazon Seller Support, I understand your concern that there will be a change of IP ad ...