当前位置:网站首页>[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
边栏推荐
猜你喜欢
利用 MATLAB 编程实现最速下降法求解无约束最优化问题
Svn detailed use tutorial
[servlet] detailed explanation of servlet (use + principle)
Thinkphp5 + data large screen display effect
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
SVN详细使用教程
每日一题-LeetCode396-旋转函数-递推
Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
LeetCode162-寻找峰值-二分-数组
随机推荐
Flink DataStream 类型系统 TypeInformation
1 - first knowledge of go language
Set up an AI team in the game world and start the super parametric multi-agent "chaos fight"
Unity_ Code mode add binding button click event
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
like和regexp差别
脏读、不可重复读和幻读介绍
Swift Protocol 关联对象 资源名称管理 多线程GCD 延迟 once
Bingbing learning notes: take you step by step to realize the sequence table
你還不知道責任鏈模式的使用場景嗎?
One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)
async关键字
三、梯度下降求解最小θ
1-初识Go语言
Introduction to distributed transaction Seata
we引用My97DatePicker 实现时间插件使用
qt之.pro文件详解
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
如何打开Win10启动文件夹?
帧同步 实现