我有这个thymeleaf模板片段:<form action="#" method="POST" th:action="@{/credentials}" th:object="${credential}"> <input type="hidden" name="credentialId" th:field="*{credentialId}" id="credential-id"> </form>
和此数据类:
'
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Credential {
private Integer credentialId;
private String url;
private String userName;
private String key;
private String password;
private Integer userid;
}`
由于credentialId
属性存在于credential:Credential对象中,我不知道为什么会出现这个错误。
我已经尝试确保我在模板中看到的与我在后端中看到的相对应,我没有观察到任何差异。
1条答案
按热度按时间qxsslcnc1#
在您的视图中,您没有使用您说要放在Model对象中的凭据,而是使用了凭据
th:object值必须与控制器中的Model匹配。