以下问题:我尝试更改文本区域的文本。
我正在使用 Sping 和 Thymeleaf。
现在我的代码看起来像这样:
Spring :
[...]
modelMap.addAttribute("Email", "035and so on");
modelMap.addAttribute("Notes", "Please take this text and use it!");
[...]
百里香:
[...]
<div class="col-sm-6 col-md-6 col-lg-6">
<input name="Tel" class="form-control" placeholder="Telefonnummer"
th:value="${Tel}" style="width: 100%;" />
</div>
<div><textarea class="form-control" rows="12"
style="margin-top: 10px;" placeholder="Sonstige Bemerkungen"
name="notes" th:field="*{Notes}">
</textarea></div>
[...]
电话字符串工作正常,但我不知道如何访问
文本区域。如果有人能帮助我,我会很高兴。
最佳答案
我发现 textarea 不支持 value 属性时遇到了同样的问题。 如果您尝试将 thymeleaf 变量插入 html 文本区域,则可以使用文本内联。所以像这样...
<div><textarea class="form-control" rows="12"
style="margin-top: 10px;" placeholder="Sonstige Bemerkungen"
name="notes" th:inline="text">[[${Notes}]]
</textarea></div>
关于java - 使用 spring-thymeleaf 访问文本区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27839870/