【问题标题】:Thymeleaf does not work with Lombok getters and settersThymeleaf 不适用于 Lombok getter 和 setter
【发布时间】:2017-06-24 18:20:57
【问题描述】:

错误

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>

知道为什么会出现此错误吗?为什么我不能将龙目岛与百里香一起使用?

【问题讨论】:

    标签: spring-mvc thymeleaf lombok


    【解决方案1】:

    错误状态为Bean property 'mytemplate' is not readable,它没有说明name 属性-at.test.Mytemplate 本身被用作thymeleaf 开始变量解析的根。

    所以只需引用name 而不是mytemplate.name

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

    【讨论】:

      猜你喜欢
      • 2020-10-11
      • 1970-01-01
      • 1970-01-01
      • 2022-06-10
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 2016-05-26
      相关资源
      最近更新 更多