框架使用規(guī)范_第1頁
框架使用規(guī)范_第2頁
框架使用規(guī)范_第3頁
框架使用規(guī)范_第4頁
框架使用規(guī)范_第5頁
已閱讀5頁,還剩51頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、框架使用規(guī)范 框架使用規(guī)范55中科軟科技股份有限公司 關(guān)于本文檔主 題框架使用規(guī)范說明本文檔用于描述在框架中如何進(jìn)行基本功能的開發(fā)。簡述了開發(fā)流程以及需要注意的事項。適用對象項目經(jīng)理,開發(fā)組,維護(hù)組,新員工入職培訓(xùn)修 訂 歷 史 版 本章 節(jié)類 型日 期作 者說 明說明:類型創(chuàng)建(c)、修改(u)、刪除(d)、增加(a);評 審 記 錄 角 色簽 名日 期說 明審 核會 簽標(biāo)準(zhǔn)化審查批 準(zhǔn)目 錄關(guān)于本文檔2一、 單表增刪改查41建立數(shù)據(jù)庫表tr_stu42建立mode類83建立表和model類的映射關(guān)系104建立dao類115建service類126 建立action類157 建立dao,se

2、rvice,action的spring配置文件188 配置struts-students.xml219 bsp_dictmgr,字典表的配置2410用表bsp_queryconfig配置查詢語句2611 用表bsp_queryinparam進(jìn)行查詢參數(shù)的配置2912 查詢頁面qrystudents.jsp;3013 增,改,查看頁面edtstudents.jsp;3314 系統(tǒng)左側(cè)目錄樹40二、 一對多關(guān)聯(lián)411 建立主子表422 建立醫(yī)療機(jī)構(gòu)科室的單表增刪改查433 建立醫(yī)生信息的單表增刪改查444定義子表的查詢類繼承基類commonqueryaction.java444.1 單表查詢時直接

3、使用基類commonqueryaction.java444.2 自定義子表的查詢類繼承自基類commonqueryaction.java444.3 在applicationcontext-action.xml里配置管理自定義的查詢類,如圖:454.4 在struts-employee.xml里對醫(yī)生信息查詢的配置,如下:465 醫(yī)生信息增加/修改頁面加上隱藏項46三、 多行添加461 多行添加說明462 建立子表(醫(yī)生的教育和工作經(jīng)歷信息)473 在主表的dao,service,action中增加對子表的處理方法473.1在主表dao中增加對子表的操作方法473.2 在主表service中增加

4、對子表的操作方法483.3 修改主表action中的方法493.4 編輯頁面edtemployee.jsp51四、 統(tǒng)計531 統(tǒng)計配置表bsp_report_config53五、 導(dǎo)出csv541 導(dǎo)出csv配置表bsp_export_one_many(該表處理有主次卡,如果沒有則不需要配置,只需在bsp_queryconfig中配置對應(yīng)的sql語句)54一、 單表增刪改查約定:系統(tǒng)名稱為培訓(xùn)范例,代碼為tr業(yè)務(wù)名稱為學(xué)生信息,代碼為stu以學(xué)生信息錄入為例,說明單表增刪改查業(yè)務(wù)的建立過程。1建立數(shù)據(jù)庫表tr_stu 表tr_stu的字段,類型如下表:字段類型注釋id_stuvarchar2

5、(40)主鍵num_stuvarchar2(20)編號sexvarchar2(2)性別(碼表tr_dd_sex)birthdaydate生日nationvarchar2(10)民族(碼表tr_dd_nation)id_cardvarchar2(18)身份證telephonevarchar2(20)電話zonevarchar2(10)地區(qū)編碼orgvarchar2(30)機(jī)構(gòu)編碼addressvarchar2(200)地址gradevarchar2(10)級別ispoorvarchar2(20)貧困與否hobbyvarchar2(100)興趣(碼表tr_dd_hobby)entrydatedat

6、e入學(xué)日期healthvarchar2(10)健康 (碼表tr_dd_health)healthdetailvarchar2(400)健康詳情healthcheckdatedate檢查日期postnumvarchar2(6)郵編emailvarchar2(40)emailremarkvarchar2(100)備注namevarchar2(20)姓名tm_createdate創(chuàng)建日期tm_updatedate更新日期empid_createvarchar2(20)創(chuàng)建者empid_updatevarchar2(20)修改者建表可參考如下語句(本語句只供參考,語句中使用的表空間并非指定,可自定義適

7、合的表空間):- create tablecreate table tr_stu( id_stu varchar2(40) not null, num_stu varchar2(20), sex varchar2(2), birthday date, nation varchar2(10), id_card varchar2(18), telephone varchar2(20), zone varchar2(10), org varchar2(30), address varchar2(200), grade varchar2(10), ispoor varchar2(2), hobby v

8、archar2(100), entrydate date, health varchar2(10), healthdetail varchar2(400), healthcheckdate date, postnum varchar2(6), email varchar2(40), remark varchar2(400), name varchar2(20) not null,tm_create date,tm_update date,empid_create varchar2(20),empid_update varchar2(20)tablespace tb pctfree 10 ini

9、trans 1 maxtrans 255 storage ( initial 64k minextents 1 maxextents unlimited );- add comments to the table comment on table tr_stu is 學(xué)生信息表;- add comments to the columns comment on column tr_stu.id_stu is pk;comment on column tr_stu.num_stu is 編號;comment on column tr_stu.zone is 地區(qū);comment on column

10、 tr_stu.org is 機(jī)構(gòu);- create/recreate primary, unique and foreign key constraints alter table tr_stu add constraint pk_tr_stu primary key (id_stu) using index tablespace tb pctfree 10 initrans 2 maxtrans 255 storage ( initial 64k minextents 1 maxextents unlimited );2建立mode類在src.ie.tr.model下建students.j

11、ava,代碼如下(省略了部分代碼):package ie.tr.model;import java.util.date;/* * students model類 * author zhl * */public class students implements java.io.serializable private string idstu;private string name;private string numstu;private string sex;private date birthday;private string nation;private string idcard;

12、private string telephone;private string zone;private string org;private string address;private string grade;private string ispoor;private string hobby;private string health;private date entrydate;private string healthdetail;private string postnum;private string email;private date healthcheckdate;pri

13、vate string remark;public string getidstu() return idstu;public void setidstu(string idstu) this.idstu = idstu;public string getname() return name;public void setname(string name) = name;/省略了部分代碼說明:(1)表tr_stu中的字段和model中的變量名一一對應(yīng),且每個變量都要生成getter,setter方法(2)類,文件的命名要規(guī)范,model的映射文件命名為students.hb

14、m.xml;service類命名為studentsservice.java,studentsserviceimpl.java,action類命名為studentsaction.java,查詢頁面命名為qrystudents.jsp,編輯頁面命名為:edtstudents.jsp等3建立表和model類的映射關(guān)系在src.ie.tr.model下建students.hbm.xml,此文件規(guī)定了表中的字段和model中的變量名一一對應(yīng)關(guān)系,如下(省略了部分代碼):!doctype hibernate-mapping public -/hibernate/hibernate mapping dtd

15、3.0/en 說明:(1)文件頭部的內(nèi)容不可隨意改動;(2)注意xml文件里各個屬性都有開始和結(jié)束標(biāo)記;(3)注意開頭要給出表名,model類的路徑class name=ie.tr.model.students table=tr_stu;中是model類中的屬性和表的每列一一對應(yīng)關(guān)系;(4)需在配置文件里給出表的主鍵生成方式,表中每條記錄要有一個唯一的標(biāo)識,為保持主鍵唯一性,避免并發(fā)時出現(xiàn)重復(fù)主鍵,因而主鍵的生成方式非常關(guān)鍵,hibernate提供多種主鍵生成機(jī)制,uuid機(jī)制基于128 位唯一值產(chǎn)生算法生成16 進(jìn)制數(shù)值(編碼后以長度32 的字符串表示)作為主鍵,是較常用的,尤其適合大量并發(fā)

16、操作時避免主鍵重復(fù)。(5) 數(shù)據(jù)庫里的數(shù)據(jù)類型對應(yīng)的不同的java數(shù)據(jù)類型,較常用的對應(yīng)關(guān)系有:db2javavarcharstringdatejava.util.date4建立dao類在src.ie.tr.dao下建立studentsdao.java,代碼如下package ie.tr.dao;import ie.bsp.frame.dao.commonbasedao;/* * dao類 * author zhl * */public interface studentsdao extends commonbasedao在src.ie.tr.dao下建立studentsdaohib.java

17、,代碼如下package ie.tr.dao.hib;import ie.bsp.frame.dao.hib.commonbasedaohib;import ie.tr.dao.studentsdao;/* * dao實現(xiàn)類 * author zhl * */public class studentsdaohib extends commonbasedaohib implements studentsdao public studentsdaohib() super();5建service類在src.ie.tr.service下建studentsservice.java,接口中定義業(yè)務(wù)方法,如

18、下:package ie.tr.service;import ie.tr.model.students;/* * service接口 * author zhl * */public interface studentsservice /* * param model */public void save(students model);/* * param model */public void edit(students model);/* * param id * return */public students get(string id);/* * param id */public

19、void delete(string id);src.ie.tr.service.impl下建studentsserviceimpl.java實現(xiàn)接口中的方法 ,如下:package ie.tr.service.impl;import ie.tr.dao.studentsdao;import ie.tr.model.students;import ie.tr.service.studentsservice;/* * service實現(xiàn)類 * author zhl * */public class studentsserviceimpl implements studentsservice/*

20、* */private studentsdao dao;public studentsdao getdao() return dao;public void setdao(studentsdao dao) this.dao = dao;/* (non-javadoc) * see ie.tr.service.studentsservice#delete(java.lang.string) */public void delete(string id) /dao.excutesql(delete from tr_stu t where t.id_stu=+id+);students model=

21、(students)dao.get(students.class, id);dao.delete(model);/* (non-javadoc) * see ie.tr.service.studentsservice#edit(ie.tr.model.students) */public void edit(students model) dao.edit(model);/* (non-javadoc) * see ie.tr.service.studentsservice#get(java.lang.string) */public students get(string id) stude

22、nts model=(students)dao.get(students.class, id);return model;/* (non-javadoc) * see ie.tr.service.studentsservice#save(ie.tr.model.students) */public void save(students model) dao.save(model);6 建立action類在src.ie.tr.action下建studentsaction.java,action類繼承基類baseeditaction。注意:類中的對象和屬性,都要生成相應(yīng)的getter,setter

23、方法;package ie.tr.action;import ie.bsp.frame.action.baseeditaction;import ie.bsp.frame.exception.generalexception;import ie.tr.model.students;import ie.tr.service.studentsservice;/* * action類 * author zhl * */public class studentsaction extends baseeditactionstudentsservice service;students students;

24、string id;public studentsservice getservice() return service;public void setservice(studentsservice service) this.service = service;public students getstudents() return students;public void setstudents(students students) this.students = students;public string getid() return id;public void setid(stri

25、ng id) this.id = id;/* (non-javadoc) * see ie.bsp.frame.action.baseeditaction#doaddparentinput() */overridepublic void doaddparentinput() throws generalexception /* (non-javadoc) * see ie.bsp.frame.action.baseeditaction#doaddparentsubmit() */overridepublic void doaddparentsubmit() throws generalexce

26、ption / todo auto-generated method stubservice.save(students);/* (non-javadoc) * see ie.bsp.frame.action.baseeditaction#doaudit() */overridepublic void doaudit() throws generalexception / todo auto-generated method stub/* (non-javadoc) * see ie.bsp.frame.action.baseeditaction#dodelteparentsubmit() *

27、/overridepublic void dodelteparentsubmit() throws generalexception service.delete(id);/* (non-javadoc) * see ie.bsp.frame.action.baseeditaction#doeditparentinput() */overridepublic void doeditparentinput() throws generalexception / todo auto-generated method stubstudents=service.get(id);/* (non-java

28、doc) * see ie.bsp.frame.action.baseeditaction#doeditparentsubmit() */overridepublic void doeditparentsubmit() throws generalexception / todo auto-generated method stubservice.edit(students);/* (non-javadoc) * see ie.bsp.frame.action.baseeditaction#doviewparentsubmit() */overridepublic void doviewpar

29、entsubmit() throws generalexception / todo auto-generated method stubthis.doeditparentinput();7 建立dao,service,action的spring配置文件在src.ie.tr.resources.spring下建立applicationcontext-dao.xml; applicationcontext-service.xml; applicationcontext-action.xml;代碼如下:說明:(1) applicationcontext-dao.xml中配置dao的實現(xiàn);appli

30、cationcontext-service.xml中配置service類中用到的dao對象的實現(xiàn);applicationcontext-action.xml中配置action類中用到的service對象的實現(xiàn);(2) applicationcontext-service.xml中引用的bean名稱必須與applicationcontext-dao.xml中的名稱相同;applicationcontext-action.xml中引用的bean名稱必須與applicationcontext-service.xml中的名稱相同;如相同顏色所標(biāo)識:applicationcontext-dao.xmla

31、pplicationcontext-service.xmlapplicationcontext-action.xml說明:(1) 配置文件中頭部定義和聲明的內(nèi)容一般不可隨意改動;(2) spring通過配置文件applicationcontext.xml來管理bean,舉例如下: class給出的是類的路徑 ,scope=prototype設(shè)置bean的作用域,讓spring每次請求創(chuàng)建一個bean;property屬性來設(shè)置這個action類中用到的service對象,由“studentsservice”來實例化這個action類中的service對象;其它配置文件的原理與此相同;8 配置s

32、truts-students.xml在src.ie.tr.resources.struts2路徑建struts-students.xml;配置當(dāng)action中各個方法執(zhí)行時頁面跳轉(zhuǎn)的路徑;注意查詢action的配置里需配置querycode和resultname,其值應(yīng)該與查詢頁面qrystudents.jsp一致。studentsquery_studentsinfoqrystudentslist/web-inf/pages/tr/qrystudents.jsp?nq=nqstudents/web-inf/pages/tr/edtstudents.jsp studentsqrystudents

33、.acstudents/web-inf/pages/tr/edtstudents.jspstudents/web-inf/pages/tr/edtstudents.jspstudentsqrystudents.acstudentsqrystudents.ac說明:以下是struts-students.xml配置文件部分代碼:name=students_addparentinput :action的名稱;class=studentsaction : action類的別名;method=addparentinput:action中的方法;:參數(shù);:執(zhí)行該action中的這個方法后,result給出

34、的是頁面跳轉(zhuǎn)的路徑。struts-students.xml和applicationcontext-action.xml中action類的名稱必須是相同的,見黃色標(biāo)識;struts-students.xml的部分代碼:students/web-inf/pages/tr/edtstudents.jspapplicationcontext-action.xml中部分代碼9 bsp_dictmgr,字典表的配置頁面很多地方需要字典表,如性別,民族等。在此以建立和管理性別字典表為例進(jìn)行說明,其它字典表的建立和配置與此相同。首先建立字典表tr_dd_sex,注意字典表字段都定義為varchar2類型,代碼如下,model中相應(yīng)地用string類型存儲。- create tablecreate table tr_dd_sex( dd_id varchar2(10) not null, dd_value varchar2(10) not null)tablespace tb pctfree 10 initrans 1 maxtrans 255 storage ( initial 64k minextents 1 maxextents unlimited );- add comments to the table comment on table tr_dd_sex is 性別;- create

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論