一、返回整型
@Controller
public class UserC {
@Autowired
private UserBizImpl impl;
@ResponseBody
@RequestMapping("/lixiang")
public Integer getAll(Integer id,String name,String password,Integer fid,Integer index){
pageUtil<User> page= new pageUtil<User>();
if(index!=null&&!index.equals("")){
page.setIndex(index);
}
impl.getAll(id, name, password, fid, page);
return page.getSize();
}
}
以上代码返回int类型。注意返回值类型需要与数据返回值类型设置为一致。
如上方Integer 类型设置,size也为Integer类型。
二、返回集合
@Controller
public class UserC {
@Autowired
private UserBizImpl impl;
@ResponseBody
@RequestMapping("/lixiang")
public List<User> getAll(Integer id,String name,String password,Integer fid,Integer index){
pageUtil<User> page= new pageUtil<User>();
if(index!=null&&!index.equals("")){
page.setIndex(index);
}
impl.getAll(id, name, password, fid, page);
return page.getPage();
}
}
以上代码返回list集合类型。注意返回值类型需要与数据返回值类型设置为一致。
如上方list类型设置。所以实体类中需要对应的page集合。
例如: