- 浏览: 480145 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (288)
- Java (70)
- Web (11)
- JSP (18)
- JavaScript (25)
- JQuery (22)
- HTML (7)
- CSS (2)
- Struts2.X (6)
- Ibatis/Mybatis (6)
- Hibernate (4)
- Spring (8)
- Oracle (23)
- MySql (9)
- Apache (1)
- Tomcat (9)
- Weblogic (2)
- Maven (6)
- Flex (0)
- Junit (2)
- Test (1)
- SVN (6)
- GIS (3)
- Android (1)
- Eclipse (10)
- Thread (3)
- JVM (1)
- Cache (2)
- Design pattern (1)
- Nosql (3)
- Linux (10)
- Hudson/Jenkins (1)
- MQ (1)
- Network (2)
- 生活工作 (5)
- 架构师之路 (6)
- 知识精华荟萃 (9)
- Interview (13)
最新评论
-
276847139:
方法很有效,我的问题就在是在父项目的.classpa ...
手动添加Maven Dependencies -
coosummer:
推荐使用http://buttoncssgenerator.c ...
button css 样式 -
lqz2012:
DBFFileReader是外部框架里面的吧,不是JDK的。楼 ...
java读取dbf文件 -
xudongcsharp:
lx13345 写道java.lang.NoSuchMetho ...
Spring常用错误 -
lx13345:
jar是hibernate3.3GA,ehcache-1.5. ...
Spring常用错误
用到Jquery插件:http://imakewebthings.com/jquery-waypoints/
示例:
处理ajax请求的servlet
示例:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>lazyload</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Infinite Scrolling with jQuery Waypoints</title> <meta name="description" content="An example of how to build an infinite scrolling page on top of the jQuery Waypoints plugin"> <meta name="viewport" content="width=480"> <script src="jslib//modernizr.custom.js"></script> </head> <body> <div id="wrapper"> <center> <table id="container" style="border:1px solid #96C2F1; background-color: #EFF7FF; width: 300px; height: 100px; margin: 0px auto;"> <tr> <td>id</td><td>name</td> </tr> <tr> <td>2</td><td>Lucy</td> </tr> <tr> <td>3</td><td>James</td> </tr> <tr> <td>4</td><td>Gaga</td> </tr> </table> </center> <div id="footer"> </div> </div> <script src="jslib/jquery-1.7.1.js"></script> <script src="jslib/waypoints.js"></script> <script type="text/javascript"><!-- $(document).ready(function() { var $loading = $("<div class='loading'><p>Loading more items…</p></div>"), $footer = $('#footer'), opts = { offset: '100%' }; $footer.waypoint(function(event, direction) { $footer.waypoint('remove'); $('body').append($loading); //alert($('#container tr:last td:first').text()); var id=$('#container tr:last td:first').text(); $.post('lazyload', {id: id}, function(data) { if(data!=-1){ //alert("call back:"+data); var jsons = eval(data); //alert(jsons); for(i in jsons){ $('#container').append("<tr><td>"+jsons[i].id+"</td><td>"+jsons[i].name+"</td></tr>"); } //$('#container').append($data.find('.article')); //$('#container').append($data); $loading.detach(); //$('.more').replaceWith($data.find('.more')); $footer.waypoint(opts); }else{ //alert('nodata'); $loading.detach(); } }); }, opts); }); --></script> </body> </html>
处理ajax请求的servlet
import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hp.bean.User; public class LazyLoadAction extends HttpServlet { /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); int id=Integer.valueOf(request.getParameter("id")); System.out.println("-----------id:"+id); List<User> list = getUserList(id, id + 30); if(list.size()>0){ StringBuilder sb=new StringBuilder(); sb.append("["); for(int i=0; i<list.size(); i++){ User u=list.get(i); sb.append("{name:'" + u.getName() + "',id:" + u.getId() + "},"); if(i==list.size()-1) sb.append("{name:'" + u.getName() + "',id:" + u.getId() + "}]"); } System.out.println(sb.toString()); out.print(sb); }else{ out.print("-1"); } out.flush(); out.close(); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } public static List<User> getUserList(int start,int end){ String url="jdbc:mysql://localhost:3306/test"; String jdbcdriver="com.mysql.jdbc.Driver"; Connection con=null; List<User> list=new ArrayList<User>(); try { Class.forName(jdbcdriver); con=DriverManager.getConnection(url, "root", "root"); String sql="select * from user where id>? and id<?"; PreparedStatement pst=con.prepareStatement(sql); pst.setInt(1, start); pst.setInt(2, end); ResultSet rs=pst.executeQuery(); while(rs.next()){ User user=new User(); user.setId(rs.getInt(1)); user.setName(rs.getString(2)); list.add(user); } rs.close(); con.close(); }catch(Exception e){ e.printStackTrace(); } return list; } }
public class User { private Integer id; private String name; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
- lazyload.rar (1.6 MB)
- 下载次数: 6
- imakewebthings-jquery-waypoints-v1.1.7-0-g7a7e8d8.zip (59.2 KB)
- 下载次数: 3
发表评论
-
jQuery密码强度插件
2014-01-17 15:24 715Complexify 是一个用来检测密码强度的 jQuery ... -
jquery 跨域提交数据
2013-12-19 17:11 11381.直接用jquery中$.getJSON进行跨域提交 ... -
实现select多选插件
2013-12-04 14:40 1006JQuery获取和设置Select选项 ... -
jQuery插件 AjaxFileUpload 异步上传
2012-12-15 14:13 888http://www.phpletter.com/Demo/ ... -
按钮禁用 启用控制
2012-12-15 13:16 977<input type="button&qu ... -
Jquery评级星型插件
2012-11-29 17:18 903Jquery评级星型插件 【官网】[url]http://w ... -
json
2012-07-23 22:15 884http://www.json.org/ tool:http ... -
滚动动态加载插件lazyload
2012-04-09 16:01 1758插件官网:http://www.appelsiini.net/ ... -
JQuery获取表单元素的值
2012-02-24 11:11 1166<body> 文本框: ... -
jquery插件之jplayer
2011-12-28 11:05 992http://www.jplayer.org -
jQuery通过$.browser来判断浏览器
2011-08-31 16:25 1412用jQuery来判断浏览器的 ... -
jquery validate
2011-08-29 21:44 1846http://topmanopensource.iteye.c ... -
jQuery过滤选择器
2011-08-22 23:24 1145jQuery过滤选择器主要是 ... -
Jquery实现Google自动补全效果
2011-05-31 10:39 1610HTML <html> <head> ... -
服务器端向客户端输出json
2011-05-09 14:47 15731.服务器端传送一个字符串到客户端,客户端通过eval()得到 ... -
append()方法使用出错
2011-04-29 16:02 1757今天用append方法时动态插入一个表格,在FF下是可以看到效 ... -
Ajax使用时间戳来解决IE缓冲问题
2011-04-24 17:10 2240当你的ajax需要的数据是及时更新的,也就是说在没有刷新页面的 ... -
JQuery常用积累(值得你进来!)
2011-04-21 17:08 18421.如何通过Jquery获取radio的值 如何通过Jquer ... -
解决AJAX中文乱码
2011-04-21 15:51 1279问题描述:在利用JQuery的$.get()方式url?use ... -
jquery validate
2011-01-15 01:39 1165一、准备工作 需要JQuery版本:1.2.6+, 兼容 1. ...
相关推荐
In this article I want to discuss the lazy loading mechanism provided by NHibernate. It is recommended for maximum flexibility to define all relations in your domain as lazy loadable. This is the ...
当应用需要加载图片时,特别是网络图片,采用“懒加载”(Lazy Loading)策略是提高性能和节省资源的有效方式。这个“IOS TableView Lazy Loading Demo”就是演示了如何将UITableView与懒加载技术相结合,以优化用户...
在网页设计中,加载效果(通常称为“页面loading效果”)是用户体验的重要组成部分。当用户访问一个网站或应用时,加载过程可能需要时间,而一个精心设计的loading动画可以缓解用户的等待焦虑,同时提升品牌形象。本...
Lazy Loading:懒加载的常见问题与解决方案.docx
Lazy Loading:JavaScript懒加载实现.docx
"lazyloading.rar"这个压缩包文件提供了一个实现移动端图片懒惰加载的解决方案。下面将详细解释这种技术的原理、优势、实现方式以及如何使用压缩包内的文件。 图片懒惰加载是一种优化策略,主要用于网页或应用中,...
Lazy Loading:视频懒加载实现方法.docx
这种技术模仿了社交媒体平台如新浪微博和Pinterest的浏览体验,让用户在滚动页面时能无缝地加载更多内容,而无需点击分页按钮。这种功能大大提升了用户浏览的流畅性,减少了用户的操作负担,尤其适用于内容丰富的...
在提供的"lazyLoading.rar"压缩包中,包含了一个完整的实现图片懒加载的实例。其中,HTML5页面应该包含了使用`data-src`的`<img>`标签,JavaScript文件(可能是.js后缀)则包含了处理滚动事件和图片加载逻辑的代码。...
"fakeLoader"是一种常见的技术,用于在页面实际内容加载前提供一种加载效果,即“loading”动画。这样的加载器可以提高用户的感知速度,因为用户在看到实际内容之前,有一个视觉反馈,表明网站正在积极处理请求。...
在本文中,我们将深入探讨如何实现页面加载的Loading效果,以及涉及到的相关技术知识点。首先,我们需要理解页面加载的过程。一般来说,网页加载分为几个阶段:HTML解析、CSS和JavaScript执行、图片和其他资源加载。...
这个模板可以帮助那些希望在自己的网站上实现类似微博功能的用户,或者用于教学、学习网页设计时模仿和理解大型社交平台的界面布局和交互设计。 在这款模板中,我们可以学习到以下几个关键的网页设计和开发知识点:...
此外,这样的加载效果还可以与其他优化策略结合,如延迟加载(lazy loading)、压缩图片和代码优化,以进一步提高页面加载速度和用户体验。 总的来说,"页面loading效果插件 for z-blog.rar" 是一个针对z-Blog用户...
页面图片的延迟加载,也称为懒加载(Lazy Load),是一种优化网页性能的技术。它通过只在用户滚动到图片所在位置时才加载图片,而非一次性加载所有图片,从而减少了初次加载页面所需的时间,提升了用户体验,特别是...
Lazy Loading:CSS懒加载策略.docx
Lazy Loading:懒加载技术概论.docx
Lazy Loading:懒加载与用户体验.docx
Lazy Loading:懒加载与SEO优化.docx
Lazy Loading:懒加载与性能优化.docx