怎样应用dwr

第一步:copy lib文件到web应用程序的web-inf/lib文件夹下面:
dwr-2.0.2.jar
bsf-2.3.jar
bsh-2.0b4.jar
commons-logging-1.0.4.jar
commons-validator-1.1.4.jar
jakarta-oro-2.0.8.jar
log4j-1.2.12.jar
第二步:修改web.xml
<listener>
   <listener-class>org.directwebremoting.servlet.DwrListener</listener-class>
</listener>
<servlet>
   <servlet-name>dwr-invoker</servlet-name>
   <servlet-class>
      org.directwebremoting.servlet.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文件 web-inf下
<!DOCTYPE dwr PUBLIC
   "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
   "http://getahead.org/dwr/dwr20.dtd">
<dwr>
   <allow>
      <create creator="new" javascript="JDate">
         <param name="class" value="java.util.Date"/>
      </create>
      <create creator="new" javascript="Demo" >
          <param name="class" value="com.dj.web.Demo"/>
      </create>
    </allow>
</dwr>
第四步:在页面中引入js文件
<script type='text/javascript' src='/AJAX_DWR/interface/Demo.js'></script>
<script type='text/javascript' src='dwr/engine.js'></script>
<script type='text/javascript' src='dwr/util.js'></script>
function updatePage(){
   var bookid=dwr.util.getValue("bookid");
    Demo.validateBookId(bookid,function(data){
        dwr.util.setValue("demoDiv",data);});
}


<script type="text/javascript">

function deleteById(){
    var userid=dwr.util.getValue("userid");
    deletedwr.deleteById(userid,function aa(data){
        alert(data);
    });
}
-------------------------------------------------
function invoke(){
    test4.getMap(
        function(map){
             for(var date in map){
                  alert(data+"?"+map[data]);
              }
         }
    );
</script>
<form><input type="text" name="userid" onblur="deleteById();"></form>
要获得文本框中的内容:
    dwr.util.getValue("name");
    $("name").value;
怎么进行同步:dwr.engine.setAsync(false);
怎么进行批处理:dwr.engine.beginBatch();
              dwr.engine.endBatch();
整合SSH:
    在dwr.xml中<create creator="spring" javascript="自定义">
                   <param name="beanName" value="spring中id的值"/>
               </create>

你可能感兴趣的:(Web,log4j,servlet,DWR,ssh)