myPagination 分页插件(ajax) + springmvc + springdata

前台





 


 


用户区域结果结果描述时间得分


 

 

后台

控制器:

@RequestMapping(value = { "/rolls/index", "/rolls" }, method = RequestMethod.GET)
 public String rollsIndex() {
  return "admin/rollsList";
 }

 @RequestMapping(value = "/rolls/list")
 @ResponseBody
 public String rollsList(@RequestParam("page") int page,
   @RequestParam("pageSize") int pageSize,
   @RequestParam("acode") String acode,
   @RequestParam("uname") String uname) {

  // Page p = rollsManager.getAllRolls(page, pageSize);

  Page p = rollsManager.getRolls(page, pageSize,acode,uname);
  Map map = Maps.newLinkedHashMap();

  map.put("result", p.getContent());
  map.put("pageCount", p.getTotalPages());

  return jsonMapper.toJson(map);
 }


 

service:

/**
  * 根据区域代码、用户名 查看博饼记录
  * 
  * @param pageIndex
  * @param pageSize
  * @param acode
  * @param userName
  * @return
  */
 public org.springframework.data.domain.Page getRolls(int pageIndex,
   int pageSize, String acode, String userName) {

  PageRequest pageRequest = new PageRequest(pageIndex - 1, pageSize,
    new Sort(Direction.DESC, "rollTime"));

  if (StringUtils.isEmpty(acode) && StringUtils.isEmpty(userName))
   return getRolls(pageRequest);

  if (StringUtils.isNotEmpty(acode) && StringUtils.isNotEmpty(userName))
   return getRollsByAreaAcodeUserName(acode,userName,pageRequest);

  if (StringUtils.isNotEmpty(acode))
   return getRollsByAcode(acode, pageRequest);

  return getRollsByUserName(userName, pageRequest);

 }


 

dao:

public interface RollsDao extends PagingAndSortingRepository,RollsDaoCustom {

	
	
	@Query("select r from Rolls r where r.area.acode = ?1 ")
	public Page findByAreaAcode(String acode,Pageable pageable);
	
	
	@Query("select r from Rolls r where r.user.name = ?1 ")
	public Page findByUserName(String name,Pageable pageable);
	
	@Query("select r from Rolls r where r.area.acode = ?1 and r.user.name = ?2 ")
	public Page findByAreaAcodeAndUserName(String acode,String name,Pageable pageable);
	
	@Query("select r from Rolls r where r.rollTimes.id = ?1 ")
	public Page findByUserRollTimesId(Long id,Pageable pageable);
	
}

 

 

官网:http://code.google.com/p/mypagination/

 

中文参数乱码解决:修改jquery.myPagination.js中

$.ajax({url:varUrl,type:'POST',data:param,contentType:"application/x-www-form-urlencoded;charset=UTF-8" ....

type:'POST'  contentType:"...charset=UTF-8"
 

你可能感兴趣的:(学习点滴)