0
イムを構築:「私は他のビューからの断片としてこのフォームを再利用したいのですが、私はできるしかしThymeleafは、私はこのようなオブジェクトをバインドすることができるようにthymeleafフォームに、コントローラからモデル属性を渡すオブジェクト
<div class="container" style="max-width: 600px" th:fragment="signupForm">
<form name="f" th:action="@{/signup}" th:object="${userCredentials}" method="post" class="form-horizontal">
<input th:placeholder="#{messages.form.email}" type="text" th:field="*{email}"
name="email" id="email" class="form-control"/>
<input th:placeholder="#{messages.form.name}" type="text" th:field="*{name}"
name="name" id="name" class="form-control"/>
<input type="password" th:placeholder="#{messages.form.password}" th:field="*{password}"
id="password" name="password"/>
<button type="submit" th:text="#{messages.form.signup}"></button>
</form>
</div>
${userCredentials}
フォームオブジェクトが初期化されていないためです。私は何とかこのような私のビューの内側にこのオブジェクトを構築することはできますか?
<div th:if="${userCredentials == null}" th:with="userCredentials=new UserCredentials()"></div>