【发布时间】:2017-03-18 11:49:33
【问题描述】:
我想知道如何在使用 Thymeleaf 将输入值发送到控制器之前修剪?
我使用 Spring MVC 和 Thymeleaf 作为模板引擎。
下面是我的表单代码:
<form id="collabForm" method="post" action="#" th:action="@{/collaborateurs/add}" role="form" th:object="${newCollaborateur}">
<div class="box-body">
<div class="form-group col-sm-6 col-md-4 col-lg-4">
<label for="nomCollab">Nom</label>
<input id="nomCollab" class="form-control" name="nom" type="text" placeholder="Saisir le nom" th:field="*{nom}" required="required"/>
</div>
</div>
</form>
非常感谢!
【问题讨论】:
-
你的输入标签通常使用
onchange="this.value = this.value.trim()"怎么样? -
感谢您的回答,但我认为有一种简单的方法可以做到这一点。我不知道怎么做,但似乎 Thymeleaf 对此有所帮助
标签: html spring-mvc thymeleaf