SpringBoot中使用thymeleaf的switch来实现if-else if -else的效果
场景
SpringBoot中使用thymeleaf的开关语句实现if-else if -else的效果。
Switch使用示例:
<div th:switch="${user.role}"><p th:case="'admin'">User is an administrator</p><p th:case="#{roles.manager}">User is a manager</p>
</div>
请注意,只要一个:case属性计算为true,其它每一个th:case属性在相同的switch中认定为false。
默认选项指定为th:case="*":
<div th:switch="${user.role}"><p th:case="'admin'">User is an administrator</p><p th:case="#{roles.manager}">User is a manager</p><p th:case="*">User is some other thing</p>
</div>
实现
<div th:switch="${info.status}"><th th:case="00">完成</th><th th:case="01">异常</th><th th:case="*">未知状态</th>
</div>
SpringBoot中使用thymeleaf的switch来实现if-else if -else的效果相关推荐
- 【SpringBoot】3、SpringBoot中整合Thymeleaf模板引擎
SpringBoot 为我们提供了 Thymeleaf 自动化配置解决方案,所以我们在 SpringBoot 中使用 Thymeleaf 非常方便 一.简介 Thymeleaf是一个流行的模板引擎,该 ...
- SpringBoot中使用thymeleaf时点击按钮触发事件失败
场景 在SpringBoot项目中使用thymeleaf模板时按钮的点击事件没法触发. 需要用到jquery的delegate()函数. delegate()函数用于为指定元素的一个或多个事件绑定事件 ...
- SpringBoot中使用thymeleaf时ajax请求不能回显消息
场景 在SpringBoot项目中使用thymeleaf模板时,在js文件中使用ajax提交表单 不能成功回显消息. 实现 修改为 html中: <button id="parseBt ...
- SpringBoot中的Thymeleaf基本使用
初次书写博客,不足之处请多体谅 Thymeleaf官方文档中英文版本 链接:link 提取码:z6od 1.Thymeleaf介绍 Thymeleaf是用来开发Web和独立环境项目的服务器端的Java ...
- SpringBoot中访问Thymeleaf提示:元素类型 meta 必须由匹配的结束标记终止。
场景 新建SpringBoot项目后整合Thymelaf后访问页面提示: 元素类型 "meta" 必须由匹配的结束标记 "</meta>" 终止. ...
- SpringBoot中整合Thymeleaf
场景 springboot不建议使用jsp,使用模板引擎,比如thymeleaf,velocity,freemarker. 项目搭建专栏: https://blog.csdn.net/BADAO_LI ...
- SpringBoot中使用Thymeleaf常用功能(二):测试Thymeleaf条件判断
环境搭建请先阅读文章一 在一的基础上 先在index.html中添加超链接 <a th:href="@{iftest}">测试条件判断</a> 在Thyme ...
- thymeleaf html模块化,SpringBoot中使用Thymeleaf模板开发的后台管理框架
系统简介 JavaWeb专业版,企业级开发框架SpringBoot+Layui+Thymeleaf+MybatisPlus开发权限(RBAC)及内容管理框架,框架中集成了权限管理.模块管理,数据库管理 ...
- Idea开发springBoot 中使用 thymeleaf 模板$表达式报红波浪线解决方案
html页面设置前如下显示: 我的Idea版本是2021.2.4,解决过程如下: 1.在idea上方菜单栏中选择File --> Settings 2.在settinngs --> In ...
最新文章
- 只是想虐下春丽,一不小心撸了台游戏机...
- matplotlib可视化必知必会富文本绘制方法
- MIPS投RISC-V是龙芯新征程的开始
- JavaScript标准对象:地图
- React开发(124):ant design学习指南之form中的属性isFieldTouched
- 前端学习(2763):基本的数据绑定
- 【数据结构与算法】【算法思想】分治算法
- [.net基础]访问修饰符
- c/c++ linux 进程 fork wait函数
- 在Ubuntu上用wine下载QQ,三种打开QQ的方法
- 2014年9月-前端开发月刊
- [虎符CTF 2021]Internal System
- CIFAR-10数据集目录结构以及数据组织格式
- 39 What Determines the Kind of Person You Are ?是什么决定了你是哪种内型的人 ?
- redis源码--SDS结构解析
- 顺时针 逆时针打印矩阵 java
- 单纤光模块与双纤光模块的区别是什么?
- css3软键盘不盖住输入框的方法
- 百度地图api之固定标记点(标记点自己设置样式)
- 服装店如何根据自身情况使用进销存软件?
热门文章
- in python_数学 in python
- SpringCloud--Eureka服务注册与发现 Eureka 集群搭建 详细案例!!!
- 支付通道接口异常统计上报
- 给定关键字不在字典中怎么解决_什么是字典?我们为什么要学它?你不知,现在你只需1分钟就可学会...
- 简述python函数调用过程_python函数定义和调用过程详解
- 利用matlab命令画出以下信号的波形,MATLAB实验报告
- JAVA 的读取Excel方法_纯Java的方式读取excel2007
- chrome 历史版本_2020 年最后一次更新,Chrome 性能大提升的新版本来了
- Khadas VIM3 (Amlogic A311D) uboot去掉烦人的乱七八糟的打印1——BL2 BL3x
- 18离线帮助文档_VIM学习笔记 Zeavim离线文档查看器