我想创建一个数据数组列表,并通过 Rest 点返回它。我试过这个:
@Service
public class CardBrandsListService {
public ArrayList<String> getCardBrandsList() {
ArrayList<String> list = new ArrayList<String>();
list.add("visa");
list.add("master");
list.add("Intl Maestro");
list.add("amex");
return list;
}
}
休息终点:
@GetMapping("/card_brand/list")
public ResponseEntity<?> getCurruncy() {
return ResponseEntity.ok(cardBrandsListService.getCardBrandsList().entrySet().stream()
.map(g -> new CardBrandsListDTO(g.getValue())).collect(Collectors.toList()));
}
断续器:
public class CardBrandsListDTO {
private String card_brand;
public String getCard_brand() {
return card_brand;
}
public void setCard_brand(String card_brand) {
this.card_brand = card_brand;
}
}
但是我得到的错误:映射数组列表的正确方法是什么?The method entrySet() is undefined for the type ArrayList<String>
BIG阳
相关分类