search
HomeJavajavaTutorialUse Struts2 to implement list display and paging function example code

BlogDAO.java file

/**Return multiple records based on conditions (default all data in one table)*/

public List<blog> list(String kw,Integer pageCur,Integer pageSize) {  
    List<blog> list = null;  
    Integer limitaInteger = (pageCur-1)*pageSize;  
    Integer limitbInteger = pageCur*pageSize;  
    Object[] params = {limitaInteger,limitbInteger};//代入的参数列表  
    String sqlWhere = "";  
    String sql = "select * from csdn_blog where first=1 ";  
    if(kw!=null && !kw.equals("")) {  
        sqlWhere = " and topic like '%"+kw+"%'";  
    }  
    sql += sqlWhere;  
    sql += " order by id desc limit ?,?";  
    ResultSetHandler<list>> rsh = new BeanListHandler<blog>(Blog.class);//把结果集转成BeanList  
    try {  
        list = qr.query(getConn(), sql, rsh, params);   //调用查询接口的查询函数  
    } catch (SQLException e) {  
        e.printStackTrace();  
    }  
    return list;  
}</blog></list></blog></blog>

BlogActin.java file

private Integer pagenum;//页码  private List<blog> allblogs;  
//并提供set  get 方法public List<blog> getAllblogs() {  
    return allblogs;  
}  
public void setAllblogs(List<blog> allblogs) {  
    this.allblogs = allblogs;  
}  

public Integer getPagenum() {  
    return pagenum;  
}  
public void setPagenum(Integer pagenum) {  
    this.pagenum = pagenum;  
}</blog></blog></blog>

----------- ---List method

/** 显示博客列表信息 */   public String alllist() {  
    request=ServletActionContext.getRequest();  
    blogtopic=request.getParameter("blogtopic");  
    allblogs=blogDAO.list(blogtopic, pagenum, 10);  
    num_allblog=blogDAO.countAllNum(blogtopic);  
    num_allblogpage=num_allblog/10+1;  
    return "index";  
}

----------JSPFile

<p>  
    <foreach>  
        <p>  
        </p>
<h1>
<a>[${allblog.topic}]</a>  
            <a>${allblog.title}</a>
</h1>  
        <dl>  
        <dt><a><img  src="/static/imghwm/default1.png" data-src="img/oyuntaolianwu.jpg" class="lazy" alt="Use Struts2 to implement list display and paging function example code" ></a></dt>  
        <dd>
<p></p>
<pre class="brush:php;toolbar:false">${allblog.content }

           

               C++指针常量               常量指针常量指针常量

           

             

             

                                                                                     
${allblog.writer}                           阅读(${allblog.reader})                           评论(${allblog.discuss}) ${allblog.time}

                             

          ${num_allblog}条数据  共${num_allblogpage}页                      [${pagenum}]                     下一页             尾页 

  

The above is the detailed content of Use Struts2 to implement list display and paging function example code. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
深度探讨Struts框架的原理与实践深度探讨Struts框架的原理与实践Feb 18, 2024 pm 06:10 PM

Struts框架的原理解析与实践探索Struts框架作为JavaWeb开发中常用的MVC框架,具有良好的设计模式和可扩展性,广泛应用于企业级应用程序开发中。本文将对Struts框架的原理进行解析,并结合实际代码示例进行探索,帮助读者更好地理解和应用该框架。一、Struts框架的原理解析1.MVC架构Struts框架基于MVC(Model-View-Con

解析Struts2框架的工作原理解析Struts2框架的工作原理Jan 05, 2024 am 08:29 AM

探秘Struts2框架的内部机制Struts2是一个流行的JavaWeb应用程序框架,被广泛应用于开发基于MVC架构的Web应用程序。它基于Struts1的基础上进行了大量的改进和优化,提供了更强大、更灵活的功能。在深入探索Struts2框架的内部机制之前,我们需要了解一些基本概念。Struts2框架的核心是MVC(Model-View-Controlle

Java后端开发:使用Java Apache Struts进行API MVC框架开发Java后端开发:使用Java Apache Struts进行API MVC框架开发Jun 17, 2023 am 10:03 AM

随着互联网和智能移动设备的普及,Web应用程序的开发日趋重要。而Java作为一种优秀的跨平台编程语言,受到了开发者们的青睐。在Java后端开发中,使用MVC框架可以帮助我们提高开发效率、降低开发成本。本文将介绍使用JavaApacheStruts进行API的MVC框架开发。一、MVC框架MVC(Model-View-Contro

struts框架的原理和应用有哪些struts框架的原理和应用有哪些Jan 03, 2024 pm 05:31 PM

struts框架的原理:通过采用Java Servlet/JSP技术,实现了基于Java EE Web应用的MVC设计模式的应用框架,它通过采用一个或多个Action类来处理用户请求,并将结果返回给用户。struts框架的应用:1、构建Web应用程序;2、处理表单数据;3、集成第三方库;4、实现国际化;5、构建RESTful API。

Java语言中的Struts框架介绍Java语言中的Struts框架介绍Jun 10, 2023 pm 08:00 PM

Java语言中的Struts框架介绍随着Web应用程序的逐渐普及,比如Web网站和企业应用系统,JavaEE(EnterpriseEdition)架构也逐渐成为了一个主流的选择。在JavaEE架构中,由于MVC(Model-View-Controller)设计模式的流行,Struts框架成为了大家经常使用的Web应用程序框架之一。在本文中,我们将深入探

深入剖析Struts2框架的运行机制深入剖析Struts2框架的运行机制Jan 05, 2024 pm 03:36 PM

深入解析Struts2框架的工作原理Struts2是一个优秀的JavaWeb应用开发框架,其提供了基于MVC(Model-View-Controller)模式的开发方式,帮助开发人员更快速地构建和维护Web应用程序。理解Struts2框架的工作原理对于开发人员来说是非常重要的,本文将通过详细的解析和具体的代码示例,帮助读者深入了解Struts2框架的工作原

Struts2框架实现原理的详细解析Struts2框架实现原理的详细解析Feb 21, 2024 pm 05:54 PM

Struts2框架实现原理的详细解析Struts2框架作为一个广泛应用的JavaWeb应用框架,其优秀的设计和性能使得它成为开发者们喜爱使用的工具。了解Struts2框架的实现原理,对于提升开发者对框架的理解和应用水平具有重要意义。本文将通过详细解析Struts2框架的实现原理,并提供具体的代码示例,帮助读者更加深入地了解这一框架。一、Struts2框架简

探究struts框架的原理及应用探究struts框架的原理及应用Jan 04, 2024 am 08:19 AM

深入解析Struts框架的原理与应用摘要:Struts框架是一个优秀的JavaWeb应用程序开发框架,其基于MVC设计模式,以及一系列的标签库和拦截器,为开发者提供了一种简单、规范的方式来构建Web应用程序。本文将深入解析Struts框架的原理与应用,包括框架的工作原理、主要组件以及通过示例代码来展示其具体的应用。一、Struts框架的工作原理Struts

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software