[英]Spring boot rest service duplicated response body
I'm using Spring Boot framework and my response returns duplicated with reversed backward.我正在使用 Spring 引导框架,我的响应返回重复的反向反向。 I'm asking for advices, how can i solve this situation?
我正在寻求建议,我该如何解决这种情况?
Controller End Point Controller 端点
@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;
}
I have @RestController annotation at top of my Controller class.我的 Controller class 顶部有 @RestController 注释。
PPreviewW response class PPreviewW 回复 class
@Getter
@Setter
public class PPreviewW implements Serializable {
public String DisplayId;
public String AccountCode;
}
I'm using lombok getters and setters我正在使用 lombok getters 和 setters
Repository Class资料库 Class
public PPreviewInfo findPByW(String W) {
PPreviewInfo list = jdbcTemplate
.queryForObject(QueryConstants.GET_P_PREVIEW_INFOW, new Object[]{W}, new PPreviewInfoMapper());
return list;
}
@Repository and @Autowired annotations at top of Repository class. and QueryContants includes my sql which returns correct size for example like XXXX and YYYY PPreviewInfo Class存储库 class 顶部的 @Repository 和 @Autowired 注释。QueryContants 包括我的 sql,它返回正确的大小,例如 XXXX 和 YYYY PPreviewInfo Class
@Getter
@Setter
public class PPreviewInfo {
public String CUSTOMER_ID;
public String BILLING_ACCOUNT_CODE;
}
PPreviewInfoMapper Class 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;
}
}
response回复
{"DisplayId":"XXXX","AccountCode":"YYYYYY","NEXTFLAG":true,"nextflag":true,"displayId":"XXXX","accountCode":"YYYYYY"}
The visibility of the attributes might be causing the issue, you can see if changing them to private might help in resolution:属性的可见性可能会导致问题,您可以查看将它们更改为私有是否有助于解决问题:
@Getter
@Setter
public class PPreviewW implements Serializable {
private String DisplayId;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.