In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you an example of the use of the mybatis paging plug-in pageHelper. I hope you will get something after reading this article. Let's discuss it together.
Working framework spring springmvc mybatis3
To first use the paging plug-in, you must first introduce maven dependencies. Add the following to pom.xml
Com.github.pagehelperpagehelper3.7.5
Second, you need to add a configuration to the configuration file. There are two ways
1. The new mybatis-config.xml content is as follows
Add a bean attribute to the spring-mybatis.xml
Load a global configuration file
Configure the scan of mapper to find all mapper.xml mapping files.
Note: if your mybatis-config.xml profile has the following alias configuration enabled:
Then your spring and mybatis integration files must add corresponding attributes, otherwise an exception will be reported when the mybatis configuration file is loaded unsuccessfully, as follows:
We have one more step here than the configuration above.
When configuring, it should be noted that the properties of the mybatis configuration file and the spring-mybatis integration file should be unified.
two。 To complete the configuration as above, the second method is as follows
Configure the following properties directly in spring-mybatis.xml
Dialect=mysql rowBoundsWithCount=true
After the configuration file is loaded, you can use it directly. The specific code is as follows:
PageHelper.startPage (Integer.parseInt (currentPage), Integer.parseInt (pageSize)); List publishTz = bbsTzDao.getPublishTz (userId); PageInfo info = new PageInfo (publishTz); map.put ("status", 1); map.put ("tzList", info.getList ()); return map
The parameters that need to be passed in the foreground are the current page and the number of page displays. Of course, the number of page displays can also be specified in the background. Generally, it is best to add the default configuration when receiving parameters as follows:
@ RequestParam (defaultValue= "1", value= "currentPage") String currentPage, @ RequestParam (defaultValue= "10", value= "pageSize") String pageSize
This is the default number of pages and entries displayed by itself if the receiving parameter is an empty string, which can be specified by itself.
After reading this article, I believe you have a certain understanding of "examples of the use of the mybatis paging plug-in pageHelper". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 234
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.