我试图将隐藏的Inmput置于形式中,但归档始终为null。
<form th:action="@{/user/subject/join}" th:object="${joinSubjectDTO}" method="post">
<table>
<tr>
<td>Password to subject:</td>
<td><input type="password" th:field="*{password}" /></td>
<td><input type="hidden" th:field="*{subjectId}" th:value="${subject.id}"/></td>
</tr>
<tr>
<td><button type="submit">Join</button></td>
</tr>
</table>
</form>
有人可以帮我解决这个问题吗?
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class JoinSubjectDTO {
private Integer subjectId;
private String password;
}
我正在添加JoarinSubjectdto class。
在线下方尝试。无需使用TD标签。将隐藏的标签写在桌子的侧面。也不指定th:值,为t:字段self是ID,名称和值。
<input type="hidden" th:field="*{subjectId}">
工作代码是:
<input type="hidden" name="subjectId" th:value="${subject.id}">