5.5 定值布尔属性

HTML有布尔属性的概念。布尔属性没有值,属性存在意味着值是“true”。在XHTML里,这些属性只有一个值,这个值就是它自己。 例如,checked

  1. <input type="checkbox" name="option2" checked /> <!-- HTML -->
  2. <input type="checkbox" name="option1" checked="checked" /> <!-- XHTML -->

标准方言包含允许你通过求值条件设置属性的属性。如果求值为true,属性将会被设置为它的定值。如果为false,属性将不会被设置:

  1. <input type="checkbox" name="active" th:checked="${user.active}" />

以下定值布尔属性存在标准方言里:

th:async th:autofocus th:autoplay
th:checked th:controls th:declare
th:default th:defer th:disabled
th:formnovalidate th:hidden th:ismap
th:loop th:multiple th:novalidate
th:nowrap th:open th:pubdate
th:readonly th:required th:reversed