使用Lombok在Springboot中无法进行模型绑定

时间:2019-06-18 02:42:11

标签: java spring-boot model-binding lombok

springboot rest控制器中我使用Lombok @Data的属性之一的属性绑定未发生

尝试使用自己的吸气剂,而不是龙目岛的二传手很好。

控制器:

$course

RequestDTO模型:

/{course}

请求有效载荷:

@PostMapping("/v1/getList")
    public List<String> getDetails(@RequestBody RequestDTO requestDTO, HttpServletRequest request) throws IOException, SQLException {}

在sysout期间,我得到: requestDTO.getScreenName():null

其余属性正确绑定。

1 个答案:

答案 0 :(得分:0)

如果其他方法工作正常,则方法命名中应该存在错误。通常,此sName字段的获取器和设置器应如下所示。

public string getsName() {
    return sName;
}

public void setsName(string sName) {
    this.sName = sName;
}

尝试使用requestDTO.get s Name();请注意,在这里s很简单。