<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    dwr 配置

    1:下載dwr.jar放在 WebRoot\WEB-INF\lib

    2:頁面
    <%@ page language="java" pageEncoding="UTF-8"%>
          <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/checkuser.js'></script>
           <script type='text/javascript'>
                function  check(form)
              {
             
               var id=document.getElementById("id").value;
               if(id=="new")
               {
               regUserChked(form);
               }
               else
               {
              
               RegUserChked(form);
                 
               }
              }
            
            
            
            
            
            
            
            
            
            
              function regUserChked(form){ 
              
                 var username= document.getElementById("username").value;
               
                
                  if(username=="")
                  {
                
                  alert("用戶名不能為空!")
               
                  return false;
                  }
                 
                  checkuser.isExist(username,showData);//showData回調(diào)函數(shù)  
                  
                   
               } 
              
                function RegUserChked(form){ 
               
                  var id=document.getElementById("id").value;
                  var username= document.getElementById("username").value;
                  if(username=="")
                  {
                
                  alert("用戶名不能為空!")
               
                  return false;
                  }
                
                    checkuser.IsExistUpdate(username,id,ShowData);  //showData回調(diào)函數(shù)  
                }
              
              
              
              
              
              
              
              function showData(data){  
                if(data){  
                  alert('該用戶已被注冊(cè)了!');
                }else{  
                  alert('該用戶未被注冊(cè)了!');  
                 }  
              }  
             
               function ShowData(data){  
                if(data){  
                  alert('該用戶已被注冊(cè)了!');
                }else{  
                  alert('可以更新!');  
                 }  
              }  
            </script>
        </head>
        <body>
            <html:form action="/acctount" onsubmit="javascript:return Juge(this);">
                <input type="hidden" name="id"  value="<%=id%>">
                username : <html:text property="username" value="<%=Username %>" onblur="check(this)" />
    <html:errors property="username"/><br/>
                password : <html:text property="password" value="<%=password %>"/>
    <html:errors property="password"/><br/>

            <html:submit/><html:cancel/>
            </html:form>
        </body>
    </html>




    3:dwr.xml配置
          <dwr>

        <allow> 
     
        
     <!-- 直接取操作類  <create creator="new" javascript="checkuser" scope="application">
          <param name="class" value="com.henry.dao.daospring"/>
           <include method="isExist"/>
        </create>
       -->
      
       <!-- 間接取bean -->
           <create creator="spring" javascript="checkuser">
          <param name="beanName" value="accountDAO" />
             <include method="isExist"/>
             <include method="IsExistUpdate"/>
           </create>
     </allow> 
    </dwr>

    4:  applicationContext.xml

       <bean id="accountDAO" class="com.henry.dao.AccountDao">
       <property name="dataSource">
         <ref local="dataSource"/>
         </property>
        <property name="sqlMapClient">
        <ref bean="sqlMapClient"/>
        </property>
       
         </bean>
    5:web.xml
       <servlet>
      <servlet-name>dwr-invoker</servlet-name>
      <display-name>DWR Servlet</display-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>
     <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    6:1)以上dwr通過間接spring-> applicationContext.xml的bean
    <!-- 間接取bean -->
           <create creator="spring" javascript="checkuser">
          <param name="beanName" value="accountDAO" />
             <include method="isExist"/>
             <include method="IsExistUpdate"/>
           </create>


       2)如果直接取spring-> applicationContext.xml的bean
    <!-- 直接取操作類  <create creator="new" javascript="checkuser" scope="application">
          <param name="class" value="com.henry.dao.daospring"/>
           <include method="isExist"/>
        </create>
       -->
     
    com.henry.dao.daospring
    :如下
    package com.henry.dao;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import  com.henry.dto.accountDto;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.context.support.FileSystemXmlApplicationContext;
    public class daospring {
        ApplicationContext context=new ClassPathXmlApplicationContext("com/henry/dbxml/applicationContext.xml");
        AccountDao testDAOImpl=(AccountDao)context.getBean("AccountDAO");
        public List getAccountsByName(String username)
        {
          
        
          return  testDAOImpl.getListByName(username);
        }
       
        /*
         * update check
         */
        public boolean IsExistUpdate(String username)
        {
            accountDto account=new accountDto();
            List list=this.getAccountsByName(username);
            if(list.size()==0)
            {
                return false;
            }
            else
            {
                //if(account.getId()==Integer.parseInt(id))
                //{
                //    return false;
                   
                //}
                //else
                //{
                    return true;
                //}
            }
        }
       
        public String getIdByName(String username,String id)
        {
            accountDto account=new accountDto();
            List list=this.getAccountsByName(username);
            if(list.size()==0)
            {
                return null;
            }
            else
            {
                return   Integer.toString(((accountDto)list.get(0)).getId()) ;
            }
           
        }
       
       
       
        public boolean IsExist(String username) { 
           
            if(testDAOImpl.isExist(username))
            {
            return true;
            }
            else
            {
                return false;
            }
          
       }
       
        //new or add   check
        public boolean isExist(String username) { 
              
            if(testDAOImpl.isExist(username))
            {
            return true;
            }
            else
            {
                return false;
            }
          
       }
       
       
        public accountDto getAccountById(String id)
        {
        return  testDAOImpl.getById(id);
        }
      
    }


    7:出現(xiàn)問題struts---->action--->findforward跳轉(zhuǎn)頁面------該頁面dwr取spring-->applicationContext.xml的bean變成無效

    posted on 2008-02-28 18:12 smallfa 閱讀(564) 評(píng)論(0)  編輯  收藏 所屬分類: jquery/dwr/extjs


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    <2008年2月>
    272829303112
    3456789
    10111213141516
    17181920212223
    2425262728291
    2345678

    導(dǎo)航

    統(tǒng)計(jì)

    公告

    smallfa
    博客園
    C++博客
    博客生活
    Blogjava
    足球博客
    微博
    Redsaga

    常用鏈接

    留言簿(2)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    相冊(cè)

    Ajax

    Blogs

    DB

    java

    Open source

    ORM

    Tools/Help

    vedio Tech

    搜索

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 久久午夜夜伦鲁鲁片无码免费| 亚洲电影免费在线观看| 最新国产AV无码专区亚洲| 2019中文字幕在线电影免费 | 亚洲色大成网站www永久男同 | 亚洲人成色7777在线观看| 99久久精品国产免费| 亚洲avav天堂av在线网毛片| 91麻豆精品国产自产在线观看亚洲| 巨波霸乳在线永久免费视频| 国产午夜亚洲精品不卡| 亚洲国产一区二区a毛片| 日韩a级毛片免费视频| 成在人线av无码免费高潮喷水 | 亚洲精品视频免费看| 污污污视频在线免费观看| 亚洲黄色网址大全| 久久久久亚洲爆乳少妇无| 最新猫咪www免费人成| 在线免费播放一级毛片| 亚洲av无码专区首页| 亚洲第一二三四区| 亚洲无码在线播放| 日韩一级免费视频| 两性刺激生活片免费视频| 久久久久国产精品免费看| 九九免费精品视频在这里| 亚洲jizzjizz在线播放久| 亚洲国产综合专区在线电影| 亚洲国产中文v高清在线观看| 美女网站免费福利视频| 无码人妻AV免费一区二区三区| 人妻无码中文字幕免费视频蜜桃| 亚洲jizzjizz在线播放久| 亚洲精品视频在线| 国产亚洲大尺度无码无码专线| 又黄又爽一线毛片免费观看| 在线不卡免费视频| 美女视频黄是免费的网址| 亚洲黄色免费电影| 久久国产乱子伦精品免费看|