后台代码:
package com.leyou.item.web;import com.leyou.common.vo.PageResult;
import com.leyou.item.pojo.Brand;
import com.leyou.item.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("brand")
public class BrandController { @Autowired
private BrandService brandService; @GetMapping("page")
public ResponseEntity<PageResult<Brand>> queryBrandByPage(
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "rows", defaultValue = "5") Integer rows,
@RequestParam(value = "sortBy", required = false) String sortBy,
@RequestParam(value = "desc", defaultValue = "false") Boolean desc,
@RequestParam(value = "key", required = false) String key) {
PageResult<Brand> result = this.brandService.queryBrandByPage(page,rows,sortBy,desc, key);
if (result == null || result.getItems().size() == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return ResponseEntity.ok(result);
}
}
通过断点看到return的数据是有的
但是在浏览器访问这个路径就只可以显示一部分数据
Brand:
package com.leyou.item.pojo;import tk.mybatis.mapper.annotation.KeySql;import javax.persistence.Id;
import javax.persistence.Table;@Table(name = "tb_brand")
public class Brand {
@Id
@KeySql(useGeneratedKeys = true)
private Long id;
private String name;// 品牌名称
private String image;// 品牌图片
private Character letter;
} PageResult:
package com.leyou.common.vo;import lombok.Data;import java.util.List;@Data
public class PageResult<T> {
private Long total; // 总条数
private Long totalPage; // 总页数
private List<T> items; // 当前页数据 public PageResult() {
} public PageResult(Long total, List<T> items) {
this.total = total;
this.items = items;
} public PageResult(Long total, Long totalPage, List<T> items) {
this.total = total;
this.totalPage = totalPage;
this.items = items;
}
}
package com.leyou.item.web;import com.leyou.common.vo.PageResult;
import com.leyou.item.pojo.Brand;
import com.leyou.item.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("brand")
public class BrandController { @Autowired
private BrandService brandService; @GetMapping("page")
public ResponseEntity<PageResult<Brand>> queryBrandByPage(
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "rows", defaultValue = "5") Integer rows,
@RequestParam(value = "sortBy", required = false) String sortBy,
@RequestParam(value = "desc", defaultValue = "false") Boolean desc,
@RequestParam(value = "key", required = false) String key) {
PageResult<Brand> result = this.brandService.queryBrandByPage(page,rows,sortBy,desc, key);
if (result == null || result.getItems().size() == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return ResponseEntity.ok(result);
}
}
通过断点看到return的数据是有的
但是在浏览器访问这个路径就只可以显示一部分数据
Brand:
package com.leyou.item.pojo;import tk.mybatis.mapper.annotation.KeySql;import javax.persistence.Id;
import javax.persistence.Table;@Table(name = "tb_brand")
public class Brand {
@Id
@KeySql(useGeneratedKeys = true)
private Long id;
private String name;// 品牌名称
private String image;// 品牌图片
private Character letter;
} PageResult:
package com.leyou.common.vo;import lombok.Data;import java.util.List;@Data
public class PageResult<T> {
private Long total; // 总条数
private Long totalPage; // 总页数
private List<T> items; // 当前页数据 public PageResult() {
} public PageResult(Long total, List<T> items) {
this.total = total;
this.items = items;
} public PageResult(Long total, Long totalPage, List<T> items) {
this.total = total;
this.totalPage = totalPage;
this.items = items;
}
}
解决方案 »
- 判断传递过来的数据跳转
- 求一关于用WORKSHOP写项目在tomcat下发布的详细配置~~(web.xml)
- 请问displaytag标签怎么样才可以像表格那样有mouseover和mouseclick事件?
- 运行一个简单的hibernate程序需要的jar
- tomcat+Myeclipse在windows下布置后的程序,怎么能转换到linux下运行.
- datasource 的配置文件应该如何定位和编写
- 一个取得文件夹下所有文件和子目录大小的方法的问题
- 我用smartupload组件做从DB2中下载大文件时,出现:堆中没有足够的存储器可用来处理语句。上载时好像游标不对。
- JB + WebLogic:JSP中引用的 GIF资源放到哪里?要打包吗?
- 大家看看我用jsp做的个人网站,请多提意见!
- vue发送axios的get请求参数为[]时,前后台报错,后台springmvc+springboot+mybatis
- 用jqgrid做的表格如何加入点击事件
不是因为这个,是因为我在实体类上忘记写get set方法了
不是因为这个,是因为我在实体类上忘记写get set方法了我的天啊,让我想了好多啊