这是我的胸腺叶表单输入字段。我想为它设置一个默认值。假设我想要将“个人”设置为默认值。如何做到这一点?
<div class="col-sm-9">
<label th:if="${#fields.hasErrors('priceSearchDTO.partyType')}" th:errors="*{priceSearchDTO.partyType}"
class="validation-message"></label>
<input type="text" th:field="*{priceSearchDTO.partyType}" placeholder="partyType"
class="form-control"/>
</div>
另外,我也尝试过这个,但它不能像普通的html字段那样工作。
<div class="col-sm-9">
<label th:if="${#fields.hasErrors('priceSearchDTO.partyType')}" th:errors="*{priceSearchDTO.partyType}"
class="validation-message"></label>
<input type="text" th:field="*{priceSearchDTO.partyType}" placeholder="partyType" value="individual"
class="form-control"/>
</div>
发布于 2018-05-31 18:01:23
有一个th:占位符属性。您可以使用此属性动态设置占位符属性的值,例如:
<input ... th:placeholder="${#object.individualPlaceholder}" ...>
或
<input ... th:placeholder="|Static and ${#object.dynamic}|" ...>
如果占位符是静态值,您仍然可以使用placeholder -属性:
<input ... placeholder="Insert something" ...>
也可以对th:占位符使用静态值。
https://stackoverflow.com/questions/50617087
复制相似问题