My map is: Map<String, String>. The issue is empty values are not sended to the postman even though when I debbug are there.
This is the api:
@GetMapping(value = Routes.URI_SUFFIX_DATA_ZIPCODES_BY_CITY_AND_ZIPCODE, produces = {MediaType.APPLICATION_JSON_VALUE})
@RegisterMetricCallReceived(appService = "getStreetsByCityAndZipCode", version = "v1", type = TYPE_REST)
public Map<String,String> getStreetsByCityAndZipCode(HttpServletRequest request,
@RequestParam(name = "city") String city,
@RequestParam(name = "zipcode") String zipcode) {
GetStreetByCityAndZipcode query = new GetStreetByCityAndZipcode();
query.setCity(city);
query.setZipcode(zipcode);
Map<String, String> result = service.getStreets("eligibility", query).orElse(null);
return result;
}
When I debugg result object, it's like that:
"PLACE DU PRIEURE" -> "01043406"
"ROUTE DE BIERNE" -> ""
"ROUTE DE GENNES SUR GLAIZE" -> "01043405"
"RUE COURTE" -> "01043399"
"RUE D ANJOU" -> "01043398"
"RUE DE GENNES" -> "04311435"
"RUE DE L EGLISE" -> "01043397"
"RUE DE LA CHENAIE" -> "04106244"
"RUE DE LA POSTE" -> "01043400"
"RUE DES GRANDS JARDINS" -> "01043401"
"RUE DES JARDINS" -> ""
"RUE DES SPORTS" -> "04415887"
But from postman, I don't receive this two:
"ROUTE DE BIERNE" -> ""
"RUE DES JARDINS" -> ""
I receive just others which have not empty values:
"PLACE DU PRIEURE" -> "01043406"
"ROUTE DE GENNES SUR GLAIZE" -> "01043405"
"RUE COURTE" -> "01043399"
"RUE D ANJOU" -> "01043398"
"RUE DE GENNES" -> "04311435"
"RUE DE L EGLISE" -> "01043397"
"RUE DE LA CHENAIE" -> "04106244"
"RUE DE LA POSTE" -> "01043400"
"RUE DES GRANDS JARDINS" -> "01043401"
"RUE DES SPORTS" -> "04415887"
I found the issue, it was due to this Bean config, when I remove it, it works as fine:
@Bean
public JacksonFix jacksonFix(RequestMappingHandlerAdapter
annotationMethodHandlerAdapter) {
return new JacksonFix(annotationMethodHandlerAdapter);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.