Thymeleaf - How to add checked attribute to input conditionally

后端 未结 5 556
滥情空心
滥情空心 2020-12-08 07:18

As you know, input component has an attribute, checked to whether mark the checkbox as enabled by default or not.



        
5条回答
  •  半阙折子戏
    2020-12-08 07:48

    According to the official thymeleaf documentation

    http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#fixed-value-boolean-attributes

    th:checked is considered as a fixed-value Boolean attribute.

    
    

    Where user.active should be a boolean.

    So in your case it should be as Andrea mentioned,

    
    

提交回复
热议问题