一、分析
此url为/query/list,根据categoryId查询数据库,查询到的数据进行分页处理page=1&rows=20
二、service 层
定义接口
继承
controller层
package com.taotao.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.taotao.common.pojo.EUDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbContent;
import com.taotao.service.ContentService;
/**
* 内容管理Controller
* <p>Title: ContentController</p>
* <p>Description: </p>
* <p>Company: www.itcast.com</p>
* @author 入云龙
* @date 2015年9月8日上午11:13:52
* @version 1.0
*/
@Controller
@RequestMapping("/content")
public class ContentController {
@Autowired
private ContentService contentService;
@RequestMapping("/save")
@ResponseBody
public TaotaoResult insertContent(TbContent content) {
TaotaoResult result = contentService.insertContent(content);
return result;
}
/**
* 内容管理列表查询
*/
@RequestMapping("/query/list")
@ResponseBody
public EUDataGridResult getContentList(long categoryId, int page, int rows) {
EUDataGridResult content=contentService.getContentList(categoryId,page,rows);
return content;
}
}
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.taotao.common.pojo.EUDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbContent;
import com.taotao.service.ContentService;
/**
* 内容管理Controller
* <p>Title: ContentController</p>
* <p>Description: </p>
* <p>Company: www.itcast.com</p>
* @author 入云龙
* @date 2015年9月8日上午11:13:52
* @version 1.0
*/
@Controller
@RequestMapping("/content")
public class ContentController {
@Autowired
private ContentService contentService;
@RequestMapping("/save")
@ResponseBody
public TaotaoResult insertContent(TbContent content) {
TaotaoResult result = contentService.insertContent(content);
return result;
}
/**
* 内容管理列表查询
*/
@RequestMapping("/query/list")
@ResponseBody
public EUDataGridResult getContentList(long categoryId, int page, int rows) {
EUDataGridResult content=contentService.getContentList(categoryId,page,rows);
return content;
}
}
运行结果