MVC+EasyUI+三层新闻网站如何实现分页查询数据功能-创新互联
这篇文章给大家分享的是有关MVC+EasyUI+三层新闻网站如何实现分页查询数据功能的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

陇西网站建设公司成都创新互联公司,陇西网站设计制作,有大型网站制作公司丰富经验。已为陇西成百上千家提供企业网站建设服务。企业网站搭建\
外贸网站建设要多少钱,请找那个售后服务好的
陇西做网站的公司定做!
MVC新闻网站建立,完成分页查询数据功能。
1、在Model里面建立NewInfo(里面存放的是新闻信息的实体信息)

然后在DAL层中建立NewInfoDal (里面存放对新闻信息的操作)
写入分页查询的代码
///
/// 分页查询
///
/// 分页开始条数
/// 分页结束条数
/// 返回查询到的list集合
public List GetPageEntityList(int start,int end)
{
string sql = "select * from(select row_number()over(order by id)as num,*from T_News)as t where t.num>=@start and t.num<=@end";
SqlParameter[] pms = {
new SqlParameter("@start",SqlDbType.Int),
new SqlParameter("@end",SqlDbType.Int),
};
pms[0].Value = start;
pms[1].Value = end;
DataTable dt = SqlHelper.ExcuteDataTable(sql,CommandType.Text,pms);
List newList = null;
if (dt.Rows.Count>0)
{
newList = new List();
NewInfo newinfo = null;
foreach (DataRow item in dt.Rows)
{
newinfo = new NewInfo();
LoadEntity(item,newinfo);
newList.Add(newinfo);
}
}
return newList;
}
///
/// 查询出页面条数
///
///
public int GetRecordCount()
{
string sql = "select count(*) from T_News";
int count = Convert.ToInt32(SqlHelper.ExecuteScalar(sql,CommandType.Text));
return count;
}
在BLL层中建立NewInfoServices(里面存放对新闻信息的逻辑处理)
DAL.NewInfoDal NewInfoDal = new DAL.NewInfoDal();
///
/// 分页查询数据
///
/// 当前页码值
/// 一个多少条数据
///
public List GetPageEntityList(int pageIndex, int pageSize)
{
int start = (pageIndex - 1) * pageSize + 1;
int end = pageSize * pageIndex;
return NewInfoDal.GetPageEntityList(start,end);
}
///
/// 查询出页面的记录数
///
///
public int GetRecordCount()
{
return NewInfoDal.GetRecordCount();
}
我们把新闻管理的url指定为/NewInfo/Index

那么就要新建NewInfo控制器 Index视图就是新闻管理页面的主页了。
新闻管理主页的布局很简单就是一个表格,所以就先在body里面写了一表格
这里用到的是easyui的框架,所以先引用文件。
然后就是通过写js代码来显示出表格的行和列
基本
文件
流程
错误
SQL
调试
- 请求信息 : 2026-06-03 03:59:46 HTTP/1.1 GET : /article/dscjdj.html
- 运行时间 : 0.3736s ( Load:0.0019s Init:0.0009s Exec:0.3660s Template:0.0047s )
- 吞吐率 : 2.68req/s
- 内存开销 : 490.67 kb
- 查询信息 : 12 queries 5 writes
- 文件加载 : 36
- 缓存信息 : 0 gets 0 writes
- 配置加载 : 130
- 会话信息 : SESSION_ID=7chdn794nja0749nmvhjrnldu5
- /home/wwwroot/bluegullmediac/wwwroot/index.php ( 1.09 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/ThinkPHP.php ( 4.61 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Think.class.php ( 12.26 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Storage.class.php ( 1.37 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Storage/Driver/File.class.php ( 3.52 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Mode/common.php ( 2.82 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Common/functions.php ( 53.56 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Hook.class.php ( 4.01 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/App.class.php ( 13.49 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Dispatcher.class.php ( 14.79 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Route.class.php ( 13.36 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Controller.class.php ( 11.23 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/View.class.php ( 7.59 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php ( 3.68 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php ( 3.88 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php ( 1.91 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Conf/convention.php ( 11.15 KB )
- /home/wwwroot/bluegullmediac/wwwroot/App/Common/Conf/config.php ( 2.16 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Lang/zh-cn.php ( 2.55 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Conf/debug.php ( 1.49 KB )
- /home/wwwroot/bluegullmediac/wwwroot/App/Home/Conf/config.php ( 0.31 KB )
- /home/wwwroot/bluegullmediac/wwwroot/App/Home/Common/function.php ( 3.33 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php ( 5.62 KB )
- /home/wwwroot/bluegullmediac/wwwroot/App/Home/Controller/ArticleController.class.php ( 6.02 KB )
- /home/wwwroot/bluegullmediac/wwwroot/App/Home/Controller/CommController.class.php ( 1.60 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Model.class.php ( 60.11 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Db.class.php ( 32.43 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php ( 16.74 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Cache.class.php ( 3.83 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Cache/Driver/File.class.php ( 5.87 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Template.class.php ( 28.16 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php ( 22.40 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Template/TagLib.class.php ( 9.16 KB )
- /home/wwwroot/bluegullmediac/wwwroot/App/Runtime/Cache/Home/7540f392f42b28b481b30614275e4e55.php ( 18.20 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php ( 0.97 KB )
- /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php ( 5.24 KB )
- [ app_init ] --START--
- Run Behavior\BuildLiteBehavior [ RunTime:0.000050s ]
- [ app_init ] --END-- [ RunTime:0.000105s ]
- [ app_begin ] --START--
- Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000103s ]
- [ app_begin ] --END-- [ RunTime:0.000147s ]
- [ view_parse ] --START--
- [ template_filter ] --START--
- Run Behavior\ContentReplaceBehavior [ RunTime:0.000069s ]
- [ template_filter ] --END-- [ RunTime:0.000096s ]
- Run Behavior\ParseTemplateBehavior [ RunTime:0.004144s ]
- [ view_parse ] --END-- [ RunTime:0.004176s ]
- [ view_filter ] --START--
- Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000048s ]
- [ view_filter ] --END-- [ RunTime:0.000061s ]
- [ app_end ] --START--
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`pid`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( pid= )
- [8] Undefined index: pid /home/wwwroot/bluegullmediac/wwwroot/App/Home/Controller/ArticleController.class.php 第 47 行.
- [8] Undefined index: db_host /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Db.class.php 第 120 行.
- [8] Undefined index: db_port /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Db.class.php 第 121 行.
- [8] Undefined index: db_name /home/wwwroot/bluegullmediac/wwwroot/ThinkPHP/Library/Think/Db.class.php 第 122 行.

0.3736s
