欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Dwr简单使用

程序员文章站 2022-05-13 11:15:50
...
Dwr下载地址:http://directwebremoting.org/dwr/downloads/index.html
Dwr使用
   web.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>  
</servlet>  
  
<servlet-mapping>  
  <servlet-name>dwr-invoker</servlet-name>  
  <url-pattern>/dwr/*</url-pattern>  
</servlet-mapping>  


  dwr.xml的声明
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">  
<dwr>  
  <allow>  
    <!-- 一个实例对应一个create节点 -->  
    <create creator="new" javascript="Ming">  
      <param name="class" value="com.ming.dwr.DwrTest"/>  
    </create>  
  </allow>  
</dwr>  
   



  java代码
  package com.ming.dwr;  
/** 
 * dwr使用测试 
 * @author Admin 
 * 
 */  
public class DwrTest {  
  
    public String hello(String str){  
        return "Hello!";  
    }  
  
}  


  jsp页面的引用
<script type="text/javascript" src="dwr/engine.js"></script>  
<script type="text/javascript" src="dwr/util.js"></script>  
<script type="text/javascript" src="dwr/interface/Ming.js"></script>  
javascript的调用
   DWREngine.setAsync(false);//设置dwr为同步执行
   Ming.hello("hello", function(data){
     var hello = data;		
   });
   DWREngine.setAsync(true);
相关标签: dwr javascript