当前位置:网站首页>[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
边栏推荐
- [proteus simulation] automatic range (range < 10V) switching digital voltmeter
- Sqlserver transaction and lock problem
- We reference My97DatePicker to realize the use of time plug-in
- Want to be an architect? Tamping the foundation is the most important
- 【JZ46 把数字翻译成字符串】
- Explanation and example application of the principle of logistic regression in machine learning
- Flink datastream type system typeinformation
- 免费在upic中设置OneDrive或Google Drive作为图床
- Share 20 tips for ES6 that should not be missed
- async关键字
猜你喜欢
1n5408-asemi rectifier diode
Leetcode exercise - 396 Rotation function
LeetCode151-颠倒字符串中的单词-字符串-模拟
Leetcode151 - invert words in string - String - simulation
Leetcode165 compare version number double pointer string
capacitance
Svn detailed use tutorial
Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
详解TCP的三次握手
Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
随机推荐
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
[stc8g2k64s4] introduction of comparator and sample program of comparator power down detection
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
8.4 realization of recurrent neural network from zero
Model location setting in GIS data processing -cesium
I/O复用的高级应用:同时处理 TCP 和 UDP 服务
[servlet] detailed explanation of servlet (use + principle)
Epoll's et, lt working mode -- example program
Leetcode149 - maximum number of points on a line - Math - hash table
UML学习_day2
冰冰学习笔记:一步一步带你实现顺序表
Select receives both normal data and out of band data
【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序
[NLP] HMM hidden Markov + Viterbi word segmentation
小红书 timestamp2 (2022/04/22)
Leetcode exercise - 396 Rotation function
封面和标题中的关键词怎么写?做自媒体为什么视频没有播放量
qt之.pro文件详解