- 浏览: 327086 次
- 性别:
- 来自: 广州
文章分类
最新评论
DWR2.x的推技术也叫DWR Reverse Ajax(逆向Ajax)主要是在BS架构中,从服务器端向多个浏览器主动推数据的一种技术。
在DWR所开的线程中使用Reverse Ajax时,通过WebContextFactory.get()获取WebContext对象,进而获取脚本Session。
在DWR之外使用Reverse Ajax时,就要用到ServerContext,在Spring环境中要得到ServerContext,就需要用到Spring的ServletContextAware接口。
一、Reverse Ajax的实现有3种方式:
DWR的逆向Ajax主要包括两种模式:主动模式和被动模式。其中主动模式包括polling和comet两种,被动模式只有piggyback这一种。
1、piggyback方式
这是默认的方式。
如果后台有什么内容需要推送到前台,是要等到那个页面进行下一次ajax请求的时候,将需要推送的内容附加在该次请求之后,传回到页面。
只有等到下次请求页面主动发起了,中间的变化内容才传递回页面。
2、comet方式
当服务端建立和浏览器的连接,将页面内容发送到浏览器之后,对应的连接并不关闭,只是暂时挂起。如果后面有什么新的内容需要推送到客户端的时候直接通过前面挂起的连接再次传送数据。
服务器所能提供的连接数目是一定的,在大量的挂起的连接没有关闭的情况下,可能造成新的连接请求不能接入,从而影响到服务质量。
3、polling方式
由浏览器定时向服务端发送ajax请求,询问后台是否有什么内容需要推送,有的话就会由服务端返回推送内容。这种方式和我们直接在页面通过定时器发送ajax请求,然后查询后台是否有变化内容的实现是类似的。只不过用了dwr之后这部分工作由框架帮我们完成了。
二、使用DWR的推技术的步骤
1、在web.xml文件中增加以下配置信息
Xml代码
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!-- DWR默认采用piggyback方式 -->
<!-- 使用polling和comet的方式 -->
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- comet方式 -->
<!--
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
-->
<!-- polling方式:在comet方式的基础之上,再配置以下参数 -->
<!--
<init-param>
<param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
<param-value>org.directwebremoting.impl.PollingServerLoadMonitor</param-value>
</init-param>
-->
<!-- 毫秒数。页面默认的请求间隔时间是5秒 -->
<!--
<init-param>
<param-name>disconnectedTime</param-name>
<param-value>60000</param-value>
</init-param>
-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!-- DWR默认采用piggyback方式 -->
<!-- 使用polling和comet的方式 -->
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- comet方式 -->
<!--
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
-->
<!-- polling方式:在comet方式的基础之上,再配置以下参数 -->
<!--
<init-param>
<param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
<param-value>org.directwebremoting.impl.PollingServerLoadMonitor</param-value>
</init-param>
-->
<!-- 毫秒数。页面默认的请求间隔时间是5秒 -->
<!--
<init-param>
<param-name>disconnectedTime</param-name>
<param-value>60000</param-value>
</init-param>
-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>Xml代码
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextAttributeListener</listener-class>
</listener>
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextAttributeListener</listener-class>
</listener>Xml代码
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextListener</listener-class>
</listener>
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextListener</listener-class>
</listener>
2、在dwr.xml中增加以下配置信息
Xml代码
<create creator="new" javascript="DWRHelper">
<param name="class" value="com.cjm.web.dwr.DWRHelper"/>
<include method="addMessage"/>
<include method="test"/>
</create>
<convert converter="bean" match="com.cjm.web.dwr.Message">
<param name="include" value="id,text"/>
</convert>
<create creator="new" javascript="DWRHelper">
<param name="class" value="com.cjm.web.dwr.DWRHelper"/>
<include method="addMessage"/>
<include method="test"/>
</create>
<convert converter="bean" match="com.cjm.web.dwr.Message">
<param name="include" value="id,text"/>
</convert>
3、pojo类Message的源码
Java代码
public class Message {
private long id = System.currentTimeMillis();
private String text;
public Message(){
}
public Message(String newText){
text = newText;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
public class Message {
private long id = System.currentTimeMillis();
private String text;
public Message(){
}
public Message(String newText){
text = newText;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
4、DWRHelper类源码
Java代码
public class DWRHelper {
private static LinkedList<Message> messages = new LinkedList<Message>();
private static ReentrantLock lock = new ReentrantLock(); //JDK5锁
public void addMessage(String text){
try{
lock.lock();
if(text!=null && text.trim().length()>0){
messages.addFirst(new Message(text));
if(messages.size()>10){
messages.removeLast();
}
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
lock.unlock();
}
//获得DWR上下文
WebContext webContext = WebContextFactory.get();
//获取当前页面URL,比如/ext3/test_tag.jsp
String currentPage = webContext.getCurrentPage();
//当前脚本sessin
ScriptSession scriptSession = webContext.getScriptSession();
//设置页面控件的值
Util util = new Util(scriptSession);
util.setValue("text", ""); //这里是清空页面输入框的值
//设置脚本sessin的属性值
scriptSession.setAttribute("uid", "cjm");
//获取脚本session的属性值
for(Iterator it=scriptSession.getAttributeNames();it.hasNext();){
String attrName = (String)it.next();
System.out.println(attrName + "=" + scriptSession.getAttribute(attrName));
}
//获取所有浏览当前页面的脚本session
Collection<ScriptSession> sessions = webContext.getScriptSessionsByPage(currentPage);
Util utilAll = new Util(sessions);
//执行客户端脚本
ScriptBuffer script = new ScriptBuffer();
script.appendScript("clientFunction(")
.appendData(scriptSession.getAttribute("uid"))
.appendScript(");");
for(ScriptSession session: sessions){
session.addScript(script);
}
//更新这些脚本session的一些元素
utilAll.removeAllOptions("messages");
utilAll.addOptions("messages", messages, "id", "text");
}
}
public class DWRHelper {
private static LinkedList<Message> messages = new LinkedList<Message>();
private static ReentrantLock lock = new ReentrantLock(); //JDK5锁
public void addMessage(String text){
try{
lock.lock();
if(text!=null && text.trim().length()>0){
messages.addFirst(new Message(text));
if(messages.size()>10){
messages.removeLast();
}
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
lock.unlock();
}
//获得DWR上下文
WebContext webContext = WebContextFactory.get();
//获取当前页面URL,比如/ext3/test_tag.jsp
String currentPage = webContext.getCurrentPage();
//当前脚本sessin
ScriptSession scriptSession = webContext.getScriptSession();
//设置页面控件的值
Util util = new Util(scriptSession);
util.setValue("text", ""); //这里是清空页面输入框的值
//设置脚本sessin的属性值
scriptSession.setAttribute("uid", "cjm");
//获取脚本session的属性值
for(Iterator it=scriptSession.getAttributeNames();it.hasNext();){
String attrName = (String)it.next();
System.out.println(attrName + "=" + scriptSession.getAttribute(attrName));
}
//获取所有浏览当前页面的脚本session
Collection<ScriptSession> sessions = webContext.getScriptSessionsByPage(currentPage);
Util utilAll = new Util(sessions);
//执行客户端脚本
ScriptBuffer script = new ScriptBuffer();
script.appendScript("clientFunction(")
.appendData(scriptSession.getAttribute("uid"))
.appendScript(");");
for(ScriptSession session: sessions){
session.addScript(script);
}
//更新这些脚本session的一些元素
utilAll.removeAllOptions("messages");
utilAll.addOptions("messages", messages, "id", "text");
}
}
5、JSP页面源码
Html代码
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type='text/javascript' src='/ext3/dwr/engine.js'></script>
<script type='text/javascript' src='/ext3/dwr/util.js'></script>
<script type='text/javascript' src='/ext3/dwr/interface/DWRHelper.js'></script>
</head>
<!-- 通过 dwr.engine.setActiveReverseAjax(true); 启动该页面的Reverse Ajax功能 -->
<body onload="dwr.engine.setActiveReverseAjax(true);sendMessage();">
<p>输入信息: <input id="text" onkeypress="dwr.util.onReturn(event, sendMessage)" />
<input type="button" value="Send" onclick="sendMessage()" /></p>
<script type="text/javascript">
function sendMessage() {
DWRHelper.addMessage(dwr.util.getValue("text"));
}
</script>
<hr/>
<select id="messages"></select>
</body>
</html>
在DWR所开的线程中使用Reverse Ajax时,通过WebContextFactory.get()获取WebContext对象,进而获取脚本Session。
在DWR之外使用Reverse Ajax时,就要用到ServerContext,在Spring环境中要得到ServerContext,就需要用到Spring的ServletContextAware接口。
一、Reverse Ajax的实现有3种方式:
DWR的逆向Ajax主要包括两种模式:主动模式和被动模式。其中主动模式包括polling和comet两种,被动模式只有piggyback这一种。
1、piggyback方式
这是默认的方式。
如果后台有什么内容需要推送到前台,是要等到那个页面进行下一次ajax请求的时候,将需要推送的内容附加在该次请求之后,传回到页面。
只有等到下次请求页面主动发起了,中间的变化内容才传递回页面。
2、comet方式
当服务端建立和浏览器的连接,将页面内容发送到浏览器之后,对应的连接并不关闭,只是暂时挂起。如果后面有什么新的内容需要推送到客户端的时候直接通过前面挂起的连接再次传送数据。
服务器所能提供的连接数目是一定的,在大量的挂起的连接没有关闭的情况下,可能造成新的连接请求不能接入,从而影响到服务质量。
3、polling方式
由浏览器定时向服务端发送ajax请求,询问后台是否有什么内容需要推送,有的话就会由服务端返回推送内容。这种方式和我们直接在页面通过定时器发送ajax请求,然后查询后台是否有变化内容的实现是类似的。只不过用了dwr之后这部分工作由框架帮我们完成了。
二、使用DWR的推技术的步骤
1、在web.xml文件中增加以下配置信息
Xml代码
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!-- DWR默认采用piggyback方式 -->
<!-- 使用polling和comet的方式 -->
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- comet方式 -->
<!--
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
-->
<!-- polling方式:在comet方式的基础之上,再配置以下参数 -->
<!--
<init-param>
<param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
<param-value>org.directwebremoting.impl.PollingServerLoadMonitor</param-value>
</init-param>
-->
<!-- 毫秒数。页面默认的请求间隔时间是5秒 -->
<!--
<init-param>
<param-name>disconnectedTime</param-name>
<param-value>60000</param-value>
</init-param>
-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!-- DWR默认采用piggyback方式 -->
<!-- 使用polling和comet的方式 -->
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- comet方式 -->
<!--
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
-->
<!-- polling方式:在comet方式的基础之上,再配置以下参数 -->
<!--
<init-param>
<param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
<param-value>org.directwebremoting.impl.PollingServerLoadMonitor</param-value>
</init-param>
-->
<!-- 毫秒数。页面默认的请求间隔时间是5秒 -->
<!--
<init-param>
<param-name>disconnectedTime</param-name>
<param-value>60000</param-value>
</init-param>
-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>Xml代码
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextAttributeListener</listener-class>
</listener>
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextAttributeListener</listener-class>
</listener>Xml代码
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextListener</listener-class>
</listener>
<listener>
<listener-class>org.directwebremoting.servlet.EfficientShutdownServletContextListener</listener-class>
</listener>
2、在dwr.xml中增加以下配置信息
Xml代码
<create creator="new" javascript="DWRHelper">
<param name="class" value="com.cjm.web.dwr.DWRHelper"/>
<include method="addMessage"/>
<include method="test"/>
</create>
<convert converter="bean" match="com.cjm.web.dwr.Message">
<param name="include" value="id,text"/>
</convert>
<create creator="new" javascript="DWRHelper">
<param name="class" value="com.cjm.web.dwr.DWRHelper"/>
<include method="addMessage"/>
<include method="test"/>
</create>
<convert converter="bean" match="com.cjm.web.dwr.Message">
<param name="include" value="id,text"/>
</convert>
3、pojo类Message的源码
Java代码
public class Message {
private long id = System.currentTimeMillis();
private String text;
public Message(){
}
public Message(String newText){
text = newText;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
public class Message {
private long id = System.currentTimeMillis();
private String text;
public Message(){
}
public Message(String newText){
text = newText;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
4、DWRHelper类源码
Java代码
public class DWRHelper {
private static LinkedList<Message> messages = new LinkedList<Message>();
private static ReentrantLock lock = new ReentrantLock(); //JDK5锁
public void addMessage(String text){
try{
lock.lock();
if(text!=null && text.trim().length()>0){
messages.addFirst(new Message(text));
if(messages.size()>10){
messages.removeLast();
}
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
lock.unlock();
}
//获得DWR上下文
WebContext webContext = WebContextFactory.get();
//获取当前页面URL,比如/ext3/test_tag.jsp
String currentPage = webContext.getCurrentPage();
//当前脚本sessin
ScriptSession scriptSession = webContext.getScriptSession();
//设置页面控件的值
Util util = new Util(scriptSession);
util.setValue("text", ""); //这里是清空页面输入框的值
//设置脚本sessin的属性值
scriptSession.setAttribute("uid", "cjm");
//获取脚本session的属性值
for(Iterator it=scriptSession.getAttributeNames();it.hasNext();){
String attrName = (String)it.next();
System.out.println(attrName + "=" + scriptSession.getAttribute(attrName));
}
//获取所有浏览当前页面的脚本session
Collection<ScriptSession> sessions = webContext.getScriptSessionsByPage(currentPage);
Util utilAll = new Util(sessions);
//执行客户端脚本
ScriptBuffer script = new ScriptBuffer();
script.appendScript("clientFunction(")
.appendData(scriptSession.getAttribute("uid"))
.appendScript(");");
for(ScriptSession session: sessions){
session.addScript(script);
}
//更新这些脚本session的一些元素
utilAll.removeAllOptions("messages");
utilAll.addOptions("messages", messages, "id", "text");
}
}
public class DWRHelper {
private static LinkedList<Message> messages = new LinkedList<Message>();
private static ReentrantLock lock = new ReentrantLock(); //JDK5锁
public void addMessage(String text){
try{
lock.lock();
if(text!=null && text.trim().length()>0){
messages.addFirst(new Message(text));
if(messages.size()>10){
messages.removeLast();
}
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
lock.unlock();
}
//获得DWR上下文
WebContext webContext = WebContextFactory.get();
//获取当前页面URL,比如/ext3/test_tag.jsp
String currentPage = webContext.getCurrentPage();
//当前脚本sessin
ScriptSession scriptSession = webContext.getScriptSession();
//设置页面控件的值
Util util = new Util(scriptSession);
util.setValue("text", ""); //这里是清空页面输入框的值
//设置脚本sessin的属性值
scriptSession.setAttribute("uid", "cjm");
//获取脚本session的属性值
for(Iterator it=scriptSession.getAttributeNames();it.hasNext();){
String attrName = (String)it.next();
System.out.println(attrName + "=" + scriptSession.getAttribute(attrName));
}
//获取所有浏览当前页面的脚本session
Collection<ScriptSession> sessions = webContext.getScriptSessionsByPage(currentPage);
Util utilAll = new Util(sessions);
//执行客户端脚本
ScriptBuffer script = new ScriptBuffer();
script.appendScript("clientFunction(")
.appendData(scriptSession.getAttribute("uid"))
.appendScript(");");
for(ScriptSession session: sessions){
session.addScript(script);
}
//更新这些脚本session的一些元素
utilAll.removeAllOptions("messages");
utilAll.addOptions("messages", messages, "id", "text");
}
}
5、JSP页面源码
Html代码
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type='text/javascript' src='/ext3/dwr/engine.js'></script>
<script type='text/javascript' src='/ext3/dwr/util.js'></script>
<script type='text/javascript' src='/ext3/dwr/interface/DWRHelper.js'></script>
</head>
<!-- 通过 dwr.engine.setActiveReverseAjax(true); 启动该页面的Reverse Ajax功能 -->
<body onload="dwr.engine.setActiveReverseAjax(true);sendMessage();">
<p>输入信息: <input id="text" onkeypress="dwr.util.onReturn(event, sendMessage)" />
<input type="button" value="Send" onclick="sendMessage()" /></p>
<script type="text/javascript">
function sendMessage() {
DWRHelper.addMessage(dwr.util.getValue("text"));
}
</script>
<hr/>
<select id="messages"></select>
</body>
</html>
发表评论
-
EasyUI和EasyUI桌面App
2013-04-15 11:56 1097http://fxz-2008.iteye.com/blog/ ... -
Jquery进度条
2013-04-12 09:08 795http://www.cnblogs.com/lhb25/ h ... -
11个适合触摸事件开发的JavaScript库
2013-04-10 09:23 767http://www.codecto.com/2012/08/ ... -
Jquery插件
2013-03-22 18:33 741http://www.cnblogs.com/ywqu/arc ... -
宝贝鱼
2013-03-18 23:54 630http://code.google.com/p/cshbbr ... -
HTML&JS MVC
2013-03-15 16:27 544http://www.bootcss.com/ http:// ... -
浏览器内核及Js引擎介绍
2013-03-15 16:18 695http://wenku.baidu.com/view/623 ... -
EXTJS Demo
2013-03-12 17:19 751http://web230531.host89.chinajs ... -
网站架构和两个3d技术
2013-01-17 16:52 0http://blog.csdn.net/lovingprin ... -
DWR数据反推实例
2013-01-16 16:42 1381http://blog.sina.com.cn/s/blog_ ... -
javascript调用服务端方法
2012-12-17 22:03 900http://www.php100.com/html/webk ... -
wireshark 协议过滤
2012-10-09 11:32 1538http://blog.csdn.net/cumirror/a ... -
一个很不错的Javascript绘图库
2012-09-27 17:18 0http://www.jgraph.com/ http://w ... -
dwr推送数据
2012-09-21 16:59 0Dwr数据推技术:http://blog.csdn.net/k ... -
Extjs4 Css美工相关
2012-09-03 10:39 2946转: http://www.sencha.com/lear ... -
Extjs下拉树组件
2012-09-03 09:40 914转: http://www.2cto.com/kf/20120 ... -
Javascript基础一(apply, call, arguments, prototype)
2012-08-22 22:42 1027//javascript: apply, call, argu ... -
Extjs4的事件实例
2012-08-09 09:11 740http://www.cnblogs.com/luluping ... -
EXTJS中的Store是如何工作的
2012-08-08 21:04 886http://idoa3l3x.blogbus.com/log ... -
Extjs中的设计模式
2012-08-03 23:06 2325ExtJS设计模式 在前 ...
相关推荐
包含了dwr推送技术的详细介绍 和 一个基于dwr推送技术的聊天实例
dwr3 推送技术,可以指定用户发送登录者。但是dwr里会有许多alert的弹出框。
基于dwr推送技术的聊天室,下载后解压,可直接运行
Dwr推送技术实现BS即时通讯,项目源代码,功能实现
dwr的反转ajax,实现服务器推送数据。
DWR服务器推送技术(实时),能实时查看注册的用户和收发的消息
基于dwr推送技术,结合jsp技术,webservice天气接口,以及发送表情技术的web聊天系统,识别电脑和手机设备,不足地方请指教,谢谢
springMVC+dwr技术实现消息推送实例,简单实例演示如何用dwr实现后台向前台主动推送消息
dwr推送jar包 DWR(Direct Web Remoting)是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开发人员开发包含AJAX技术的网站。它可以允许在浏览器里的代码使用运行在WEB服务器上的JAVA函数,...
DWR是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开发人员开发包含AJAX技术的网站。它可以允许在浏览器里的代码使用运行在WEB服务器上的JAVA函数,就像它就在浏览器里一样。
这是一个简单的spring与dwr的整合,希望对大家能有一点帮助
使用DWR服务器推送技术实现聊天功能,在线的所有用户以及用户发送的消息都有服务器“推”给客户端进行显示。
按领导要求开发一个后台消息自动推送到前端显示的需求,所以用了dwr技术,后台mq监听消息,然后把监听到的消息直接推送到前端展现
DWR服务器推送技术案例代码和教程 通过js脚本配置,浏览器这端就可以调用WEB服务器的Java方法了。核心就是通过<scrip type='text/javascript'src='/dwrtest/dwr/interfae/DwrPush.js'>[removed]来实现的。DwrPush...
基于DWR框架的Web推送技术实现的web聊天程序,可以从这个代码开始了解web推送技术以及dwr框架
学习DWR技术的最好用的代码,反向推送到html页面的技术
包含 dwr2.0 dwr3.0 dwr3.0+Spring 三种推送的方法可执行代码 有ppt介绍 还有readme 如不能运行请仔细阅读 三种方式略有差异可互补
dwr反向ajax使用,即时提醒。WEB网页实现右下角时时弹出提醒DIV