0
在我当前的应用程序中,通过使用init binder-StringTrimmerEditor,我们将取消view/templates
中的所有空值。但是现在我想删除一个字段(movielist
)作为这个特定字段的无效状态,当我编辑表格时,即删除movie-list
中的所有值,然后单击保存按钮控制器获得空字符串的空值。我希望它是空字符串而不是空值。Spring initBinder StringTrimmerEditor - 排除某些字段
我该如何排除movielist无效。
<form action="#" th:object="${CustomerForm}" th:action="@{customer/save}" method="post">
<input type="hidden" th:field="*{id}"/>
<textarea th:field="*{movieList}"></textarea>
<div class="modal-footer">
<input class="btn-submit" type="submit" value="Save"/>
</div>
</form>
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(String.class, new StringTrimmerEditor(emptyAsnull:true));
}
它没有工作我:( – dummy
它工作吗?我看到你接受了答案。 –