Is there any way to check both null and empty condition in Thymeleaf?
Approach 1
1) .variable1?.variable2?.variable3
2) variable!=null
3) variable!=''
If we combine two conditions like (variable!='' And variable!=null) I am having issue when rendering.
I am trying following sample
${#strings.concat(#strings.concat('class ',variable1?.variable2), ' ', variable1?.variable2?.variable3)}
I also used containsKey as well but it is behaving differently.
Try ${#strings.isEmpty(variable)}
.
From Tutorial | Using Thymeleaf | Strings:
/*
* Check whether a String is empty (or null). Performs a trim() operation before check
*/
${#strings.isEmpty(name)}