当前位置:网站首页>[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?:''}:deptIdby 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
边栏推荐
- 【无标题】
- Practice of unified storage technology of oppo data Lake
- Brute force of DVWA low -- > High
- 科技的成就(二十一)
- How to upload large files quickly?
- Swift - Literal,字面量协议,基本数据类型、dictionary/array之间的转换
- 在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
- 解决computed属性与input的blur事件冲突问题
- SQLSERVER事物与锁的问题
- Is asemi ultrafast recovery diode interchangeable with Schottky diode
猜你喜欢

免费在upic中设置OneDrive或Google Drive作为图床

8.3 language model and data set

Model location setting in GIS data processing -cesium

Do (local scope), initializer, memory conflict, swift pointer, inout, unsafepointer, unsafebitcast, success

《JVM系列》 第七章 -- 字节码执行引擎

A good tool: aardio

Explain TCP's three handshakes in detail

UML项目实例——抖音的UML图描述

抑郁症治疗的进展

你还不知道责任链模式的使用场景吗?
随机推荐
Sqlserver transaction and lock problem
Explain TCP's three handshakes in detail
LeetCode151-颠倒字符串中的单词-字符串-模拟
免费在upic中设置OneDrive或Google Drive作为图床
Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
How does eolink help telecommuting
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
PCIe X1 插槽的主要用途是什么?
Little red book timestamp2 (2022 / 04 / 22)
Want to be an architect? Tamping the foundation is the most important
capacitance
脏读、不可重复读和幻读介绍
Daily question - leetcode396 - rotation function - recursion
Is asemi ultrafast recovery diode interchangeable with Schottky diode
3、 Gradient descent solution θ
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
在游戏世界组建一支AI团队,超参数的多智能体「大乱斗」开赛
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
2-GO variable operation