【发布时间】:2018-12-16 16:43:35
【问题描述】:
我想从 Spring rest api 返回 List:
@GetMapping("merchant_country")
public ResponseEntity<?> getMerchantCountry() {
return ok(Contracts.getSerialversionuid());
}
我想从这里获取内容:
private Map<String, Object> getCountryNameCodeList() {
String[] countryCodes = Locale.getISOCountries();
Map<String, Object> list = new HashMap<>();
for (String countryCode : countryCodes) {
Locale obj = new Locale("", countryCode);
list.put(obj.getDisplayCountry().toString(), obj.getCountry());
}
return list;
}
如何映射结果?
【问题讨论】:
-
您要返回地图或列表吗?两种方法之间没有关系吗?
-
好的,当我从角码调用 GET 商人国家时,如何将 getCountryNameCodeList 作为地图返回?
-
你不能把列表设置为地图的值吗?
-
这是开始的好地方spring.io/guides/tutorials/rest@PeterPenzov
标签: java spring spring-boot response httpresponse