如有不明确的地方,戏迎增加QQ群交流:66728073
一,下载并导入jquery easyui的导
二,jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%>文章管理
文章ID | 文章标题 | 写作时间 | 作者 |
---|
//jquery-ui中,用于格式化date日期 function formatDate(val, row) { var datetime = new Date(); datetime.setTime(val); var year = datetime.getFullYear(); var month = datetime.getMonth() + 1 < 10 ? "0"+ (datetime.getMonth() + 1) : datetime.getMonth() + 1; var date = datetime.getDate() < 10 ? "0" + datetime.getDate(): datetime.getDate(); var hour = datetime.getHours() < 10 ? "0" + datetime.getHours(): datetime.getHours(); var minute = datetime.getMinutes() < 10 ? "0"+ datetime.getMinutes() : datetime.getMinutes(); var second = datetime.getSeconds() < 10 ? "0"+ datetime.getSeconds() : datetime.getSeconds(); return year + "-" + month + "-" + date + " " + hour + ":" + minute+ ":" + second;}三,springmvc后台处理
/** * 获取文章 * @author guangshuai.wang * 2014-10-14上午12:10:40 * @param type * @param request * @param nowpage 当前页,这个是jquery-easyui自己主动提交的能參数,參数名必须为page * @param rows 每页显示的记录数,这个是jquery-easyui自己主动提交的參数,參数名必须为rows * @return */ @RequestMapping("/getAllBlogs/{type}") @ResponseBody public String getAllBlogs(@PathVariable("type")int type,HttpServletRequest request,@RequestParam("page") int nowpage,@RequestParam("rows") int rows){ List四,我自己封闭了一个返回类,用于返回jquery easyui封装的json串blogList = blogManager.getAllBlogByType(type); request.setAttribute("blogList", blogList); int totalBlogs = blogManager.getAllBlogCountByType(type); Pages pages = new Pages(totalBlogs, nowpage, rows); pages.setUrl("blog/getAllBlogs/" + type + "/"); request.setAttribute("pageInfo", pages); //return "/jsp/blog/allBlog"; ResponseResult result = new ResponseResult(); result.setTotal(100); result.setRows(blogList); return JSON.toJSONString(result); }
package com.gametech.entity;public class ResponseResult { //这两个成员的命不能变 private int total; private Object rows; public int getTotal() { return total; } public void setTotal(int total) { this.total = total; } public Object getRows() { return rows; } public void setRows(Object rows) { this.rows = rows; } }如有不明确的地方,戏迎增加QQ群交流: 66728073