当前位置:网站首页>[thymeleaf] handle null values and use safe operators
[thymeleaf] handle null values and use safe operators
2022-04-23 14:55:00 【sayyy】
<input id="treeId" name="treeId" type="hidden" th:value="${dept?.deptId?:''}"/>
<input id="treeName" name="treeName" type="hidden" th:value="${dept?.deptName?:''}"/>
${dept?.deptId}
: Use safe operators , Prevent throwingNullPointerException
${dept?.deptId?:''}
:deptId
by null when , Output''
spring el The expression sets the default value
Reference resources here .
When no default value is set ,deptId
by null when , Will be output null
.
<input id="treeId" name="treeId" type="hidden" th:value="${dept.deptId}"/>
After setting the default value ,deptId
by null when ,, Will be output ''
.
<input id="treeId" name="treeId" type="hidden" th:value="${dept.deptId?:''}"/>
spring el Expression security operator
Reference resources here .
After using the security operator , Don't worry about NullPointerException
了 .
When there is no safe operator ,dept
Variable is null when ,${dept.deptId}
Will throw out NullPointerException
.
<input id="treeId" name="treeId" type="hidden" th:value="${dept.deptId}"/>
After using the safe operator ,dept
Variable is null when ,${dept?.deptId}
And will not throw NullPointerException
.
<input id="treeId" name="treeId" type="hidden" th:value="${dept?.deptId}"/>
版权声明
本文为[sayyy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231454059333.html
边栏推荐
猜你喜欢
Redis master-slave synchronization
博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
nuxt项目:全局获取process.env信息
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file
How to upload large files quickly?
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
自动化的艺术
8.4 realization of recurrent neural network from zero
随机推荐
[untitled]
PCIe X1 插槽的主要用途是什么?
eolink 如何助力远程办公
Explain TCP's three handshakes in detail
I/O复用的高级应用之一:非阻塞 connect———使用 select 实现(也可以用 poll 实现)
Programming philosophy - automatic loading, dependency injection and control inversion
Advanced application of I / O multiplexing: Processing TCP and UDP services at the same time
January 1, 1990 is Monday. Define the function date_ to_ Week (year, month, day), which realizes the function of returning the day of the week after inputting the year, month and day, such as date_ to
Alexnet model
Pnpm installation and use
剑指 Offer II 019. 最多删除一个字符得到回文(简单)
async关键字
Svn detailed use tutorial
UML项目实例——抖音的UML图描述
nuxt项目:全局获取process.env信息
MySQL报错packet out of order
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
GIS数据处理-cesium中模型位置设置
编程哲学——自动加载、依赖注入与控制反转
8.3 language model and data set