Creating empty data-attributes in Thymeleaf
问题 I'm attempting to create an element in Thymeleaf 3.0.3 (Spring 4.3.7) with a custom data-attribute: <input th:attr="data-customAttr=${item.getMyAttr()}" /> If the result of item.getMyAttr() was 'someVal', then the rendered HTML comes out to be: <input data-customAttr='someVal' /> However, if the result of item.getMyAttr() is an empty string, the custom attribute is thrown out by Thymeleaf altogether. The rendered HTML looks like: <input /> I need to know whether the custom attribute was