Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer one of your questions at least:</p> <p>You can pass the page number and other parameters from the JSP to your controller with the RequestParam annotation like this:</p> <pre><code> @RequestMapping(value = "/list", method = RequestMethod.GET) public String getEmployees(@RequestParam(value = "page", required = false) Long page, ModelMap model) { //now page is available. model.addAttribute("employees", this.employeeService.getEmployees(page)); return "listing"; } </code></pre> <p>And your link will look something like this:</p> <pre><code> list/?page=1 </code></pre> <hr> <p>Pagination is a fairly complicated process but here are a few ideas. You can use JSTL on the JSP page to implement the logic. For instance:</p> <pre><code> &lt;c:if test="${page &gt; 1}"&gt; &lt;li class="active"&gt;&lt;a href="#"&gt;First&lt;/a&gt;&lt;/li&gt; &lt;/c:if&gt; </code></pre> <p>I suggest that you do some calculations in the Action for the number of pages that you want to display. Say for instance that you always want to display ten links. On page 1, you will display pages 1...10, on page 7 you will display pages 2...12 and so on. In the action you can determine the starting page and the ending page to display.</p> <pre><code> int startpage = page - 5 &gt; 0?page - 5:1; int endpage = startpage + 10; </code></pre> <p>On the JSP page you can do a loop maybe:</p> <pre><code> &lt;c:forEach begin="${startpage}" end="${endpage}" var="p"&gt; &lt;a href="#"&gt;${p}&lt;/a&gt; &lt;/c:forEach&gt; </code></pre> <p>and so on.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload