2017-02-07 14 views
0

ошибокThymeleaf не работает с Ломбок добытчиками и сеттеров

org.springframework.beans.NotReadablePropertyException: Invalid property 'mytemplate' of bean class [at.test.Mytemplate]: Bean property 'mytemplate' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? 

Cause: org.thymeleaf.exceptions.TemplateProcessingException Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' 

Класс

@Data 
@Builder 
public class Mytemplate{ 

    String name; 

} 

HTML

<form id="myform" class="form-horizontal" data-toggle="validator" method="POST" role="form" th:action="@{'/save'}" th:object="${mytemplate}"> 
    <input type="text" class="form-control" th:field="*{mytemplate.name}" required="required"/> 
</form> 

Любая идея, почему я получаю эту ошибку? Почему я не мог использовать ломбок с тимелеафом?

ответ

1

Ошибка Bean property 'mytemplate' is not readable, это ничего не говорит о свойстве name - сам по себе используется как корень для тимелеафа для запуска разрешения переменной.

Так просто ссылаться name вместо mytemplate.name:

<input type="text" class="form-control" th:field="*{name}" required="required"/> 

 Смежные вопросы

  • Нет связанных вопросов^_^