我正在用我的Thymeleaf / Tiles应用程序寻找以下反图案的干净解决方案:
我有两种形式(到目前为止位于两个不同的模板中),它们完全相同,但指向不同URL的th:action属性却是相同的。
第一种形式:
<form th:object="${advertisementInfo}" th:action="@{/advertisement/family/new}" method="post" class="form-horizontal">
<div th:if="${#fields.hasErrors('*')}" class="alert alert-danger form-group">
<ul>
<li th:each="err : ${#fields.errors('*')}" th:text="${err}"></li>
</ul>
</div>
<input type="hidden" th:field="*{advertisement.id}"/>
<div th:class="${#fields.hasErrors('advertisement.needs')}? 'form-group error':'form-group'">
<label class="control-label col-lg-3" for="needs" th:text="#{advertisement.family.form.needs}">Needs</label>
<div class="col-lg-6">
<select multiple="multiple" th:field="*{advertisement.needs}" class="form-control">
<option th:each="need: ${needs}" th:value="${need}" th:text="#{${'domain.enum.need.' + need}}"></option>
</select>
</div>
</div>
第二种形式是相同的,但是th:action属性如下:th:action="@{/advertisement/family/edit}"
我想到了几种方法来解决我的这种反模式:
tiles:include
。th:action
某种方式使变量的值具有。但是,如果遇到相同问题的人可以向我建议最佳做法,我将不胜感激。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句