`
phyeas
  • 浏览: 161767 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

DWR的三种Reverse Ajax Mode配置详解

阅读更多
Dwr的Reverse Ajax可分为两中基本的mode.一种是Active,另一种是Passive,在Active中又分为三种.
  • Full Streaming Mode
  • Early Closing Mode
  • Polling Mode
  • 在DWR应用中.默认启用的是Full Streaming Mode .它是三种modes中最快的一种.它每60秒检查一次浏览器是否是活跃的.配置很简单:

    <servlet>
      
    <servlet-name>dwr-invoker</servlet-name>
      
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
      
    <init-param>
        
    <param-name>activeReverseAjaxEnabled</param-name>
        
    <param-value>true</param-value>
      
    </init-param>
    </servlet>
    然后在要使用Reverse Ajax的页面使用
    dwr.engine.setActiveReverseAjax(true);
    即可...在2.0.4以后的版本中还要加入
    <init-param>
      
    <param-name>maxWaitAfterWrite</param-name>
      
    <param-value>-1</param-value>
    </init-param>
    因为在2.0.4版本中默认是使用Early Closing Mode

    Early Closing Mode:
    在2.0.4以后的版本中不需要添加配置..而2.0.3以前的版本需要、添加
    <init-param>
      
    <param-name>maxWaitAfterWrite</param-name>
      
    <param-value>500</param-value>
    </init-param>

    If it is deemed unwise to hold connections open at all then DWR can use polling mode

     

    <init-param>
      
    <param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
      
    <param-value>org.directwebremoting.impl.PollingServerLoadMonitor</param-value>
    </init-param>


    In polling mode the default poll rate is every 5 seconds. This can be customized using the following:

    <init-param>
      
    <param-name>disconnectedTime</param-name>
      
    <param-value>60000</param-value>
    </init-param>

    The example above will poll only once every 60 seconds (60,000 milliseconds). For many applications a response time of 60 seconds will be enough, and will allow a web server to handle a very large number of clients.

    测试环境:IE8.0,Firefox 2.0,Windows xp sp2,Tomcat 6.0,MsSQL Server 2000
    使用技术:Spring,Hibernate.Ext.DWR
    用第一种配置的时候IE运行不了.报异常 "要完成操作的数据尚未准备好",Firefox可以.
    第二种配置在maxWaitForWrite少于200的情况下IE运行正常,Firefox运行正常.
    第三种配置只能打开一个连接.再想打开第二个则会报   java.lang.IllegaStateException:Cannot create a session after response has been commited
    很是郁闷...若将maxWaitForWrite设置为100.则两个浏览器均没问题..但是浏览器久无刷新动作就无法从服务器调用客户端
    这篇文章望抛砖引玉..各位讲下你们是如何配置的

     

    参考资料:http://getahead.org/dwr/reverse-ajax/configuration

    分享到:
    评论

    相关推荐

    Global site tag (gtag.js) - Google Analytics