title: how can i implement a pagination in spring jdbcTemplate
body: <p>here is my following dao implementaion</p>
  
  <pre><code>@Override
      public List&lt;UserAddress&gt; getAddresses(int pageid,int total) {
  
          String sql = "select * FROM user_addresses order by id desc limit "+(pageid-1)+","+total;
          List&lt;UserAddress&gt; userAddresses  = jdbcTemplate.query(sql, new RowMapper&lt;UserAddress&gt;() {
              @Override
              public UserSessionLog mapRow(ResultSet rs, int rowNum) throws SQLException {
                  UserAddress userAdd = new UserAddress();
                  userAdd.setId(rs.getInt("id"));
                  userAdd.setId(rs.getString("city"));
                  return userSession;
              }
          });
          return userAddresses;
      }
  </code></pre>
  
  <p>in the above dao implementaion, i list all the user addresses, trying to list with limit </p>
  
  <pre><code>@RequestMapping("/userAddresses/{pageid}")
         public ModelAndView userAddresses(@PathVariable int pageid) {
          int total=5;  
          if(pageid==1){}  
          else{  
              pageid=(pageid-1)*total+1;  
          }  
           List&lt;UserAddress&gt; listAddresses = userAddressFacade.getAddresses(pageid,total);
           return new ModelAndView("userAddresses", "listAddresses", listAddresses);
      }
  </code></pre>
  
  <p>this is my view part,</p>
  
  <pre><code>&lt;table class="table table-condensed"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Address1&lt;/th&gt;
                  &lt;th&gt;City&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;c:if test="${not empty addresses}"&gt;
                  &lt;c:forEach var="address" items="${addresses}"&gt;
                      &lt;tr&gt;
                          &lt;td&gt;${address.address1}&lt;/td&gt;
                          &lt;td&gt;${address.city}&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/c:forEach&gt;
              &lt;/c:if&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
       &lt;br/&gt;  
     &lt;a href="/pro/userAddress/1"&gt;1&lt;/a&gt;   
     &lt;a href="/pro/userAddress/2"&gt;2&lt;/a&gt;   
     &lt;a href="/pro/userAddress/3"&gt;3&lt;/a&gt;  
  </code></pre>
  
  <p>I have hardcoded the pagination part, do any one have idea, how to do pagination.  i am newbie to java jdbcTemplate, </p>