基於J2EE的SSH整合應用及操作樣本二(CRUD操作及配置)

來源:互聯網
上載者:User

CRUD是指在做計算處理時的增加(Create)、查詢(Retrieve)(重新得到資料)、更新(Update)和刪除(Delete)幾個單詞的首字母簡寫。主要被用在描述軟體系統中資料庫或者持久層的基本操作功能。

In computing, CRUD is an acronym for create, retrieve, update, and delete. It is used to refer to the basic functions of a database or persistence layer in a software system.

C reate new records

R etrieve existing records

U pdate existing records

D elete existing records.

在響應新增部門請求中,通過匯入Struts 的設定檔(struts-config.xml) 來完成商務程序的部署。它把depAdd.jsp 和depAdd.do 串連起來。depAdd.jsp上產生客戶請求,depAdd.do 則對請求產生響應、處理jsp頁面上的資料。當點擊depAdd.jsp 上的儲存按鈕

(  <div style="float: right; padding: 10px 25px 0 0;">
       <div class="right_button">
       <a href="#" onclick="check();return false;"><bean:message
                 key="go.add" /> </a>
       </div>
</div>)

先檢查頁面資料的正確性,校正通過後將輸入資料用Set方法存入到userinfoForm這個FormBean中。

function check()
     {
       var userName = document.userinfoForm.userName.value;
       var password = document.userinfoForm.password.value;
       var length = document.userinfoForm.password.value.length;
       var repassword = document.userinfoForm.repassword.value;
         var tel = document.userinfoForm.tel.value;
         var department = document.userinfoForm.department.value;
      if(userName=="")
       {
         alert('部門管理員姓名不可為空!')
         return false;
       }

       if(password=="")
       {
         alert('密碼不可為空!')
         return false;
       }
       if(length<6||length>10)
       {
         alert('密碼必須大於6個字元小於10個字元!')
         return false;
       }
       if(repassword=="")
       {
         alert('重複密碼不可為空!')
         return false;
       }
       if(password!=repassword)
       {
         alert('密碼輸入不一致!')
         return false;
       }
       if(tel!="")
       {
         No = "0123456789()+-"
         for(i=0; i<tel.length; i++)
         {
                   var Checkstr = tel.charAt(i);
                     if (No.indexOf(Checkstr)== -1)
                     {
                             alert("聯絡電話格式不正確!");
                             return false;
                     }
                  }
       }
             if(department=="")
       {
         alert('部門管理員所屬部門不可為空!')
         return false;
       }

       else
       {
         document.userinfoForm.submit();
       }

}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.