Spring 启动 rest 服务重复的响应正文

Spring boot rest service duplicated response body

我正在使用 Spring 启动框架和我的回复 returns 重复并向后反转。 求教,这种情况怎么解决?

控制器端点

@GetMapping("/getPDetailsW/{W}")
public PPreviewW getPDetailsPreviewW(@PathVariable String W) {

   DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
   LocalDateTime now = LocalDateTime.now();
   String nullCheckBill = "bos";
   PPreviewW response = new PromoPreviewWGsm();

   PPreviewInfo pPreviewInfo = listRepository.findPByW(W);
   log.info(dtf.format(now) + "|getPDetailsPreviewW|" + W+ "|için istek atıldı.");

   response.setDisplayId(pPreviewInfo.getDISPLAY_ID());
   response.setAccountCode(pPreviewInfo.getACCOUNT_CODE());

   if (pPreviewInfo.W!= "bos") {
       nullCheckBill = promoPreviewInfo.W;
   }

   if (nullCheckBill == "bos") {
       response.setNEXTFLAG(Boolean.FALSE);
   } else {
       response.setNEXTFLAG(Boolean.TRUE);
   }
   return response;
}

我的控制器顶部有 @RestController 注释 class。

PPreviewW 响应 class

@Getter
@Setter
public class PPreviewW implements Serializable {

    public String DisplayId;
    public String AccountCode;
}

我正在使用 lombok getter 和 setter

存储库Class

public PPreviewInfo findPByW(String W) {
    PPreviewInfo list = jdbcTemplate
            .queryForObject(QueryConstants.GET_P_PREVIEW_INFOW, new Object[]{W}, new PPreviewInfoMapper());

    return list;
}

存储库顶部的@Repository 和@Autowired 注释class。 QueryContants 包括我的 sql 其中 returns 正确的大小例如 XXXX 和 YYYY PPreviewInfo Class

@Getter
@Setter
public class PPreviewInfo {

    public String CUSTOMER_ID;
    public String BILLING_ACCOUNT_CODE;
}

PPreviewInfoMapper Class

public class PPreviewInfoMapper implements RowMapper<PPreviewInfo> {
    @Override
    public PPreviewInfo mapRow(ResultSet rs, int i) throws SQLException {

        PPreviewInfo pbn = new PPreviewInfo();

        pbn.setDISPLAY_ID(rs.getString("DISPLAY_ID"));
        pbn.setACCOUNT_CODE(rs.getString("ACCOUNT_CODE"));
        return pbn;
    }
}

回应

{"DisplayId":"XXXX","AccountCode":"YYYYYY","NEXTFLAG":true,"nextflag":true,"displayId":"XXXX","accountCode":"YYYYYY"}

属性的可见性可能是导致问题的原因,您可以查看将它们更改为私有是否有助于解决问题:

@Getter
@Setter
public class PPreviewW implements Serializable {

    private String DisplayId;