当前位置:网站首页>[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
边栏推荐
- 【NLP】HMM隐马尔可夫+维特比分词
- Redis master-slave synchronization
- Leetcode exercise - 396 Rotation function
- The art of automation
- [jz46 translate numbers into strings]
- LeetCode151-颠倒字符串中的单词-字符串-模拟
- Achievements in science and Technology (21)
- Realization of four data flow modes of grpc based on Multilingual Communication
- Redis主从同步
- Swift - Literal,字面量协议,基本数据类型、dictionary/array之间的转换
猜你喜欢

8.2 text preprocessing

How does eolink help telecommuting

Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

Leetcode exercise - 396 Rotation function

LeetCode 练习——396. 旋转函数

Thread synchronization, life cycle

Swift Protocol 关联对象 资源名称管理 多线程GCD 延迟 once
![[detailed explanation of factory mode] factory method mode](/img/56/04fa84d0b5f30e759854a39afacff2.png)
[detailed explanation of factory mode] factory method mode

Swift - literal, literal protocol, conversion between basic data types and dictionary / array
随机推荐
SVN详细使用教程
Detailed analysis of SQL combat of Niuke database (26-30)
Flink DataStream 类型系统 TypeInformation
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
Realization of four data flow modes of grpc based on Multilingual Communication
Difference between like and regexp
科技的成就(二十一)
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
Sword finger offer II 019 Delete at most one character to get palindrome (simple)
LeetCode162-寻找峰值-二分-数组
How to write the keywords in the cover and title? As we media, why is there no video playback
每日一题-LeetCode396-旋转函数-递推
Async void caused the program to crash
Little red book timestamp2 (2022 / 04 / 22)
8.5 concise implementation of cyclic neural network
I/O复用的高级应用:同时处理 TCP 和 UDP 服务
Unity_ Code mode add binding button click event
Brute force of DVWA low -- > High
Thinkphp5 + data large screen display effect
【Proteus仿真】自动量程(范围<10V)切换数字电压表