A few days ago, I shared the implementation of paging by handwritten SQL pagination query here. Now let’s take a look at using the mybatis paging plugin pagehepler to implement paging.
The reason for using the paging plug-in is to simplify the writing of SQL code and achieve better physical paging, which can also reduce errors than writing a complete paging SQL code.
Mybatis paging plugin demo Project address: free-Mybatis_PageHelper_jb51.rar
I use the maven project implementation here:
1. First import the dependencies of the paging plugin:
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.0.0</version> </dependency>
2. Configure the paging interceptor plug-in
There are two configuration page interceptor plug-ins for official documents
1. Configure the Interceptor Plug-in in MyBatis Configuration xml
<!-- The location of plugins in the configuration file must meet the requirements, otherwise an error will be reported. The order is as follows: properties?, settings?, typeAliases?, typeHandlers?, objectFactory?, objectWrapperFactory?, plugins?, environments?, databaseIdProvider?, mappers?--><plugins> <!-- com.github.pagehelper is the package name where the PageHelper class is located--> <plugin interceptor="com.github.pagehelper.PageInterceptor"> <!-- Use the following method to configure parameters, and there will be all parameters introduced later--> <property name="param1" value="value1"/> </plugin></plugins>
2. Configure the Interceptor Plugin in the Spring Configuration File
Using spring's attribute configuration method, you can use the plugins attribute to configure it like the following:
<bean id="sqlSessionFactory"> <!-- Pay attention to other configurations--> <property name="plugins"> <array> <bean> <property name="properties"> <!--Configure parameters using the following method, configure one line--> <value> params=value1 </value> </property> </bean> </array> </property></bean>
Here I use the second type in my project, and the parameters in it are configured according to the actual situation, or they can be configured without
3. Calling methods
Mapper layer SQL statements are written according to the general query method, without writing paging:
<!-- Pagination query--> <select id="finds" resultType="country"> SELECT id, countryname, countrycode FROM country </select>
mapper layer interface:
/** * Query* @param params * @return*/public List<Country> finds();
service service service layer interface:
/** * Pagination query* @param params Pagination parameters pageNo (page number), pageSize (number of queries per page) * @return */ public PageInfo<Country> finds(Params params);
service business layer implementation class: PageHelper.startPage(1, 10); the first parameter indicates which page, and the second parameter indicates the number of records displayed on each page
After executing the PageHelper.startPage(1, 10); statement, the first select method immediately following will be paginated: List<Country> blogs = countryMapper.finds();
Then use PageInfo to wrap the query results, PageInfo<Country> pageInfo = new PageInfo<Country>(blogs);
and return pageInfo to the control layer
/** * Query*/ public PageInfo<Country> finds(Params params) //Query int pageNo = params.getPageNo(); int pageSize = params.getPageSize(); PageHelper.startPage(pageNo, pageSize); List<Country> blogs = countryMapper.finds(); //Wrap the result with PageInfo<Country> pageInfo = new PageInfo<Country>(blogs); return pageInfo; }
After returning pageInfo here, pass the params pagination parameters and parse pageInfo at the controller layer:
List<Country> clist = pageInfo.getList(); Then put the clist into scope, and use <c:forEach></c:forEach> to loop to obtain paging data/** * Home page, and pagination query* @return */ @RequestMapping("/index") public ModelAndView index(Params params){ ModelAndView modelAndView = new ModelAndView(); //First the first page, query 10 params.setPageNo(1); params.setPageSize(10); PageInfo<Country> pageInfo = countryService.finds(params); List<Country> clist = pageInfo.getList(); //Quantity of query long couts = countryService.counts(); modelAndView.addObject("clist", clist); modelAndView.addObject("couts", couts); modelAndView.setViewName("index"); return modelAndView; }The above are all the implementation codes for key pages. Now look at the codes for all configurations and implementations:
pom.xml
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.krry</groupId> <artifactId>maven_pagehepler_ora</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>maven_pagehepler_ora</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- MyBatis Generator --> <!-- Java Interfaces and Entity Classes --> <targetJavaProject>${basedir}/src/main/java</targetJavaProject> <targetMapperPackage>com.isea533.mybatis.mapper</targetMapperPackage> <targetModelPackage>com.isea533.mybatis.model</targetModelPackage> <!-- XML generation path --> <targetResourcesProject>${basedir}/src/main/resources</targetResourcesProject> <targetXMLPackage>mapper</targetXMLPackage> <!-- Compile jdk version--> <jdk.version>1.6</jdk.version> <!-- Dependency version--> <mybatis.version>3.3.1</mybatis.version> <mapper.version>3.3.6</mapper.version> <pagehelper.version>5.0.0</pagehelper.version> <mysql.version>5.1.29</mysql.version> <spring.version>4.1.2.RELEASE</spring.version> <mybatis.spring.version>1.2.4</mybatis.spring.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <!--web--> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>javax.websocket</groupId> <artifactId>javax.websocket-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>javax.transaction-api</artifactId> <version>1.2</version> </dependency> <!--Spring--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> </dependency> <dependency> <groupId>org.springframework</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> </dependency> <!--spring-oxm dependencies--> <dependency> <groupId>org.codehaus.castor</groupId> <artifactId>castor-xml</artifactId> <version>1.3.3</version> </dependency> <!--spring-json dependency--> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> <version>2.4.2</version> </dependency> <!--spring-aop dependency--> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.2</version> </dependency> <!--upload file--> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <!--mysql--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <!--druid--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.0.11</version> </dependency> <!--Mybatis--> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>${mybatis.spring.version}</version> </dependency> <!-- Mybatis Generator --> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.2</version> <scope>compile</scope> <optional>true</optional> </dependency> <!--Page plugin--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>${pagehelper.version}</version> </dependency> <!--General Mapper--> <dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper</artifactId> <version>${mapper.version}</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-framework-bom</artifactId> <version>${spring.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependency> </dependency> </dependencyManagement> <repositories> <repository> <id>nexus</id> <name>local private nexus</name> <url>http://maven.oschina.net/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>sonatype-nexus-releases</id> <name>Sonatype Nexus Releases</name> <url>http://oss.sonatype.org/content/repositories/releases</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>sonatype-nexus-snapshots</id> <name>Sonatype Nexus Snapshots</name> <url>http://oss.sonatype.org/content/repositories/snapshots</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repository> </repository> </repository> </build> <plugins> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build></project>applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd "> <!-- Configuration package scanning --> <context:component-scan base-package="com.krry"></context:component-scan> <!-- Import external resource files --> <context:property-placeholder location="classpath:jdbc.properties" /> <!-- Configure druid data source--> <bean id="dataSource" init-method="init" destroy-method="close"> <property name="driverClassName" value="${db.driver}" /> <property name="url" value="${db.url}" /> <property name="username" value="${db.username}" /> <property name="password" value="${db.password}" /> </bean> <!-- Register the transaction manager --> <bean id="txMgr" > <property name="dataSource" ref="dataSource"></property> </bean> <!-- Enable the transaction annotation driver --> <tx:annotation-driven transaction-manager="txMgr" /> <!-- Configure mybatis' sqlSessionFactory --> <bean id="sqlSessionFactory"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:mybatis-config.xml"></property> <property name="typeAliasesPackage" value="com.krry.entity"/> <property name="plugins"> <array> <bean> <!-- The configuration here mainly demonstrates how to use it. If you don't understand it, you must remove the following configuration --> <property name="properties"> <value> </value> </property> </bean> </array> </property> </bean> <!-- The configuration can scan a scanner that can scan the Mapper as a whole --> <bean> <!--If there are multiple report paths, just separate them with commas--> <property name="basePackage" value="com.krry.mapper"></property> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </beans>mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> <!-- Global mapper enable cache--> <setting name="cacheEnabled" value="true" /> <!-- Turn off the instant loading of the associated object for performance--> <setting name="lazyLoadingEnabled" value="true" /> <!-- Set the form of loading of the associated object. Here is a load field on demand (the load field is specified by SQL). All fields of the associated table will not be loaded to improve performance-> <setting name="aggressiveLazyLoading" value="false" /> <!-- For unknown SQL queries, different result sets are allowed to be returned to achieve a common effect--> <setting name="multipleResultSetsEnabled" value="true" /> <!-- Allow to use column labels instead of column names--> <setting name="useColumnLabel" value="true" /> <!-- Allow to use custom primary key values (such as UUID 32-bit encoding generated by the program as key values), and the PK generation strategy of the data table will be overwritten --> <setting name="useGeneratedKeys" value="true" /> <!-- Give nested resultMap support for field-attribute mapping --> <setting name="autoMappingBehavior" value="FULL" /> <!-- Cache SQL for batch update operations to improve performance --> <setting name="defaultExecutorType" value="BATCH" /> <!-- Timeout if the database has not responded for more than 25,000 seconds --> <setting name="defaultStatementTimeout" value="25" /> <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/> </settings> <typeAlias> <!--Alias for custom user object--> <!-- <typeAlias type="com.krry.mybatis.sysmanage.entity.User" alias="user"/> --> <!-- Batch definition alias--> <package name="com.krry.entity" /> </typeAliases> </configuration>
springmvc.xml
<?xml version="1.0" encoding="UTF-8" ?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <!-- Turn on the annotation mode driver --> <bean /> <!-- Turn on the annotation mode of mvc user also registers a ConversionService subclass FormattingConversionServiceFactoryBean--> <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <bean/> <bean/> <bean> <bean> <property name="prefixJson" value="false" /> <property name="objectMapper"> <bean> <!-- Handle the date type in the responseBody--> <property name="dateFormat"> <bean> <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss" /> </bean> </property> <!-- Not displayed when the field is null --> <property name="serializationInclusion"> <value type="com.fasterxml.jackson.annotation.JsonInclude.Include">NON_NULL</value> </property> </bean> </property> <property name="supportedMediaTypes"> <list> <value>application/json;charset=UTF-8</value> <value>application/x-www-form-urlencoded;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <!--Scan package--> <context:component-scan base-package="com.krry.controller"></context:component-scan> <!-- Access to static resource files must be set, because in the springmvc configuration, all requests (.do, addUser, js/image/css) in this project will be parsed by springmvc, and all static resource files must be filtered and released--> <!-- Choose one of the following static resource filtering--> <!--<mvc:default-servlet-handler//> --> <mvc:resources mapping="/resource/**" location="/resource/" /> <!-- View rendering jsp/freemaker/velocity--> <bean> <!-- Create a path to the page storage--> <property name="prefix" value="/WEB-INF/pages/"></property> <!-- File suffix--> <property name="suffix" value=".jsp"></property> </beans>
jdbc.properties and log4j.properties don't need to be displayed, they are almost the same
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>maven_pagehepler</display-name> <welcome-file-list> <welcome-file>index/index</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>maven_pagehepler</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>maven_pagehepler</servlet-name> <url-pattern>/index/index</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-mapping> <servlet-name>maven_pagehepler</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping></web-app>
Entity class: Country.java
package com.krry.entity;public class Country { /** * Primary key*/ private Integer id; /** * Name*/ private String countryname; /** * Code*/ private String countrycode; public Country(Integer id, String countryname, String countrycode) { this.id = id; this.countryname = countryname; this.countrycode = countrycode; } /** * Get the primary key* * @return Id - primary key*/ public Integer getId() { return id; } /** * Set primary key* * @param id Primary key*/ public void setId(Integer id) { this.id = id; } /** * Get name* * @return countryname - Name*/ public String getCountryname() { return countryname; } /** * Set name* * @param countryname Name*/ public void setCountryname(String countryname) { this.countryname = countryname; } /** * Get code* * @return countrycode - Code*/ public String getCountrycode() { return countrycode; } /** * Set code* * @param countrycode code*/ public void setCountrycode(String countrycode) { this.countrycode = countrycode; }}Params.java
package com.krry.entity;/** * * Params * @author krry * @version 1.0.0 * */public class Params { private Integer pageSize = 10; private Integer pageNo = 0; public Integer getPageNo() { return pageNo; } public void setPageNo(Integer pageNo) { this.pageNo = pageNo; } public Integer getPageSize() { return pageSize; } public void setPageSize(Integer pageSize) { this.pageSize = pageSize; }} Persistence layer: CountryMapper.java
package com.krry.mapper;import java.util.List;import com.krry.entity.Country;/** * * Mapper: Operate database* @author krry * @version 1.0.0 * */public interface CountryMapper { /** * Query* @param params * @return */ public List<Country> finds(); /** * Calculate* com.krry.dao.admin * Method name: countBlogs * @author krry * @param params * @return int * @exception * @since 1.0.0 */ public long counts(); } CountryMapper.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.krry.mapper.CountryMapper" > <!-- Pagination query--> <select id="finds" resultType="country"> SELECT id, countryname, countrycode FROM country </select> <!-- Query the number of blogs--> <select id="counts" resultType="long"> SELECT count(*) FROM country </select> </mapper>
Business layer interface:
package com.krry.service;import java.util.HashMap;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.apache.ibatis.annotations.Param;import com.github.pagehelper.PageInfo;import com.krry.entity.Country;import com.krry.entity.Params;/** * service layer: handle business logic (implemented in impl) * @author asusaad * */public interface ICountryService { /** * Pagination query for all blogs* @param params pagination parameters pageNo (page number), pageSize (number of queries per page) * @return */ public PageInfo<Country> finds(Params params); /** * Calculate the number of blogs* @param params * @return */ public long counts(); } Business layer implementation class
package com.krry.service.impl;import java.util.HashMap;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.web.servlet.ModelAndView;import com.github.pagehelper.PageHelper;import com.github.pagehelper.PageInfo;import com.krry.entity.Country;import com.krry.entity.Params;import com.krry.mapper.CountryMapper;import com.krry.service.ICountryService;/** * Implementing the service layer interface* @author asusaad * */@Servicepublic class CountryService implements ICountryService{ @Autowired private CountryMapper countryMapper; /** * Query*/ public PageInfo<Country> finds(Params params) { //Query int pageNo = params.getPageNo(); int pageSize = params.getPageSize(); PageHelper.startPage(pageNo, pageSize); List<Country> blogs = countryMapper.finds(); //Wrap the result with PageInfo PageInfo<Country> pageInfo = new PageInfo<Country>(blogs); return pageInfo; } /** * Calculation* @param params * @return */ public long counts(){ long couts = countryMapper.counts(); return couts; }} Control layer: KrryController.java
package com.krry.controller;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import org.junit.Test;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 org.springframework.web.servlet.ModelAndView;import com.github.pagehelper.PageInfo;import com.krry.entity.Country;import com.krry.entity.Params;import com.krry.service.ICoCom.** * KrryController * controller layer, forwarded as request* @author asusaad * */@Controller // means that it is a multi-case pattern, and the web layer returned by each user is different @RequestMapping("/index")public class KrryController { @Autowired private ICountryService countryService; /** * Home page, and pagination query* @return */ @RequestMapping("/index") public ModelAndView index(Params params){ ModelAndView modelAndView = new ModelAndView(); //First the first page, query 10 params.setPageNo(1); params.setPageSize(10); PageInfo<Country> pageInfo = countryService.finds(params); List<Country> clist = pageInfo.getList(); //Quantity of query long couts = countryService.counts(); modelAndView.addObject("clist", clist); modelAndView.addObject("couts", couts); modelAndView.setViewName("index"); return modelAndView; } /** * Pagination query for ajax request* @param params * @return */ @ResponseBody @RequestMapping("/loadData") public HashMap<String, Object> loadData(Params params){ HashMap<String, Object> map = new HashMap<String, Object>(); PageInfo<Country> pageInfo = countryService.finds(params); List<Country> clist = pageInfo.getList(); map.put("clist", clist); return map; }// }The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.