栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

具有分页API的Spring RestTemplate

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

具有分页API的Spring RestTemplate

将读取Rest API响应的代码更改为;

ParameterizedTypeReference<RestResponsePage<MyObject>> responseType = new ParameterizedTypeReference<RestResponsePage<MyObject>>() { };ResponseEntity<RestResponsePage<MyObject>> result = restTemplate.exchange(url, HttpMethod.GET, null, responseType);List<MyObject> searchResult = result.getBody().getContent();

这是我为RestResponsePage创建的类

package com.basf.gb.cube.seq.vaadinui.util;import java.util.ArrayList;import java.util.List;import org.springframework.data.domain.PageImpl;import org.springframework.data.domain.Pageable;public class RestResponsePage<T> extends PageImpl<T>{  private static final long serialVersionUID = 3248189030448292002L;  public RestResponsePage(List<T> content, Pageable pageable, long total) {    super(content, pageable, total);    // TODO Auto-generated constructor stub  }  public RestResponsePage(List<T> content) {    super(content);    // TODO Auto-generated constructor stub  }    public RestResponsePage() {    super(new ArrayList<T>());  }} 


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/400486.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号