電力系統(tǒng)技術(shù)總結(jié)筆記0天_第1頁
電力系統(tǒng)技術(shù)總結(jié)筆記0天_第2頁
電力系統(tǒng)技術(shù)總結(jié)筆記0天_第3頁
電力系統(tǒng)技術(shù)總結(jié)筆記0天_第4頁
電力系統(tǒng)技術(shù)總結(jié)筆記0天_第5頁
已閱讀5頁,還剩144頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

電力系統(tǒng)總結(jié)筆一:項目第一天(項目框架jar包(1)在 .elec.中創(chuàng)建publicpublicclassElecTextimplementsjava.io.Serializable<?xml<?xmlversion="1.0"encoding="UTF-<!DOCTYPEhibernate- "-//Hibernate/HibernateMap DTD3.0//EN" <class .ElecText"<idname="textID"type="string"<generator<propertyname="textName"type="string"<propertyname="textDate"type="date"<propertyname="textRemark"type="string"privateStringtextID; privateStringtextName; privateDatetextDate; privateStringtextRemark;//測試備publicStringgetTextID()return}publicvoidsetTextID(StringtextID)this.textID=}publicStringgetTextName()return}publicvoidsetTextName(StringtextName)this.textName=}publicDategetTextDate()return}publicvoidsetTextDate(DatetextDate)this.textDate=}publicStringgetTextRemark()return}publicvoidsetTextRemark(StringtextRemark)this.textRemark=}}><?xml<?xmlversion="1.0"encoding="UTF-<!DOCTYPEhibernate-configuration"-//Hibernate/HibernateConfigurationDTD3.0//EN"連接數(shù)據(jù)庫的信息 <property<property<property<property<!--加 文件-- (4)junittestpublicclassTestHibernatepublicvoidConfigurationconfiguration=newConfiguration(); SessionFactorysf=configuration.buildSessionFactory();Sessions=sf.openSession();Transactiontr= ecText=newElecText();elecText.setTextDate(newDate());}}第四步:DAO在cn..elec.dao中創(chuàng)建2個接口(公用接口和業(yè)務(wù)接口publicpublicinterfaceICommonDao<T>voidsave(T}業(yè)務(wù)接口(需要繼承公共接口,并且指定泛型TpublicpublicinterfaceIElecTextDaoextendsICommonDao<ElecText>publicstaticfinalStringSERVICE_NAME= }在 .elec.dao.impl中創(chuàng)建2個接口的實(shí)現(xiàn)}}publicvoidsave(Tentity)}publicfinalvoidsetSessionFactoryDi(SessionFactorysessionFactory){}ICommonDao<T>publicclassCommonDaoImpl<T>extendsHibernateDaoSupportpublicclassElecTextDaoImplextendsCommonDaoImpl<ElecText>IElecTextDao}}srcspring的配置文件<?xmlversion="1.0"encoding="UTF-<beans <!--1:開啟對注解的支持,組件的自動掃描,掃描在類上定義的@Controller@Service .elec的包--> ponent-scanbase- 2先不寫,大家想想項目中應(yīng)該添加什么? <beanid="sessionFactory"加載類路徑下的hibernate.cfg.xml<property 事務(wù)管理器(切面<beanid="trManager"<propertyname="sessionFactory"5:注解,在Service的類或者是Service的方法上,添加@Transcational()注解,用來控制事務(wù)--><tx:annotation-driventransaction-<!--<tx:advice<tx:adviceid="aa"transaction-<tx:methodname="update*"isolation="DEFAULT"propagation="REQUIRED"read-only="false"/><tx:methodname="delete*"isolation="DEFAULT"propagation="REQUIRED"read-only="false"/><tx:methodname="*"read-<aop:pointcutexpression="execution(* .elec.service..*.*(..))"id="bb"/><aop:advisoradvice-ref="aa"pointcut-junitpublicpublicclassTestDaopublicvoidApplicationContextac=newIElecTextDaoelecTextDao=(IElecTextDao) ecText=newElecText();elecText.setTextDate(newDate());}}使用hibernate的方式提交事務(wù)(自動提交)<property 第五步:Service在cn..elec.service中創(chuàng)建接口publicpublicinterfaceIElecTextServicepublicstaticfinalStringSERVICE_NAME void }(2)publicclassElecTextServiceImplimplementsIElecTextServiceprivateIElecTextDaoelecTextDao;publicvoidsaveElecTex ecText){}}(3)使用junit由于由于spring提供的式事務(wù)處理,進(jìn)行事務(wù)的控制,在業(yè)務(wù)層的類和方法上定義publicclassTestServicepublicvoidsave(){ApplicationContextac=newIElecTextServiceelecTextService=(IElecTextService) ecText=newElecText();elecText.setTextDate(newDate()); }}@Transactional(),同時去掉hibernate.cfg.xml中的配置,由spring控制。去掉的代<property 第六步:控制層(@Scoevalue=prototyeAction是多實(shí)例,多線程publicclassElecTextActionextendsecText=privateIElecTextServicepublicStringreturn"save";}}publicpublicClassentityClass=tryentity=(T)}catch(Exceptione){}TprotectedHttpServletRequestprotectedHttpServletResponseModelDriven<T>,ServletRequestAware,ServletResponseAwarepublicclassBaseAction<T>extendsActionSupport}}publicTgetModel()return}publicvoidsetServletRequest(HttpServletRequestreq)this.request=}publicvoidsetServletResponse(HttpServletResponseres)this.response=}}在cn..elec.util包下創(chuàng)建公用類(泛型轉(zhuǎn)換publicclassTUtilspublicclassTUtilspublicstaticClassgetTClass(Classentity){ParameterizedTypeparameterizedType=(ParameterizedType)ClassentityClass=(Class)return}}srcstruts2<?xml<?xmlversion="1.0"encoding="UTF-<!DOCTYPEstruts"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.3//EN" <constantname="struts.devMode"<!--設(shè)置 <constantname="struts.ui.theme" <constantname="struts.action.extension"系統(tǒng)管理<package<packagename="system"namespace="/system"extends="struts-<actionname="elecTextAction_*"class="elecTextAction"<result<web-appversion="2.5"" <web-appversion="2.5"" 器)--<<e-<點(diǎn)擊【保存】完成。測試保存ElecTextSSHpublicclassCommonDaoImpl<T>extendsHibernateDaoSupport ICommonDao<T>ICommonDao<T>ClassentityClass=publicfinalvoidsetSessionFactoryDi(SessionFactorysessionFactory)}publicvoidsave(Tentity)}publicvoidupdate(Tentity)}publicTfindObjectByID(Serializableid)return(T)this.getHibernateTemplate().get(entityClass,}publicvoiddeleteObjectByIDs(Serializable...ids)if(ids!=null&&for(SerializableObjectentity=this.findObjectByID(id);}}}publicvoiddeleteObjectByCollection(List<T>list)} *SELECToFROMElecTextoWHERE1=1 ANDo.textNameLIKE'%張%' ANDo.textRemarkLIKE'%張%' ORDERBYo.textDateASC,o.textName publicList<T>findCollectionByConditionNoPage(StringfinalObject[]params,Map<String,String>orderby)Stringhql="SELECToFROM"+entityClass.getSimpleName()+"oWHERE1=1";StringorderByHql=this.initOrderByHql(orderby);finalStringfinalHql=hql+condition+ List<T>list=this.getHibernateTemplate().find(finalHql, SessionFactorysf= Sessions= Queryquery= query.setParameter(0, query.setParameter(1, List<T>list=List<T>list=this.getHibernateTemplate().execute(newHibernateCallback(){publicObject nHibernate(Sessionsession)throwsHibernateException,SQLException{Queryquery=session.createQuery(finalHql);if(params!=null&¶ms.length>0){for(inti=0;i<params.length;i++){query.setParameter(i,params[i]);}}return}return}privateStringinitOrderByHql(Map<String,String>orderby){StringBufferbuffer=newStringBuffer("");if(orderby!=null&&orderby.size()>0){buffer.append("ORDERBYforfor(Map.Entry<String,String>map:orderby.entrySet()){buffer.append(map.getKey()+""+map.getValue()+",");}}return}}4Mavenpom.xml通過坐標(biāo)(jar包導(dǎo)入到項目中,如果版本升級,只需要改ssh(SSH)ssh需要的pom.xml第一步:在eclipsemaven工程maven工程src/main/javajava文件src/main/resources:存放配置文件src/test/javajava文件5Svn優(yōu)點(diǎn):使得項目組開發(fā)代碼使用svn服務(wù)器進(jìn)行版本控制常用令:Share查看svn的。6:java7(stuts2+sprin+hiberate二:項目第二天(運(yùn)行(2)(3)標(biāo)題是/title.jsp左側(cè)菜單是frame框架改變是<FRAMESETborder=0frameSpacing=0rows=82,*<FRAMESETborder=0frameSpacing=0rows=82,*frameBorder=0<FRAMEname=topFramenoResizeontextPath<FRAMESETid="main"border="0"frameSpacing="0"frameBorder="0"<FRAME<framename="changeButton"ontextPath/left.jsp"ontextPath/change.jsp"marginHeight=0marginWidth=0scrolling=no<FRAMEontextPath/loading.jsp"(4)(5)ontextPath.css"ontextPath<linkrel="stylesheet"ontextPath.css"ontextPath<linkrel="stylesheet"<script ontextPath <script ontextPath<linktype="text/css"ontextPath}/script/jquery-ztree-<scriptontextPath}/script/jquery-<script<TABLE<TABLEborder=0<TDwidth=340pxalign=center<div<ul Tree"class="tree"id第二步:tree.js ={setting:{isSimpleData:true,treeNodeKey:"mid",treeNodeParentKey:"pid",showLine:true,root:isRoot:true,nodes:[] ={setting:{isSimpleData:true,treeNodeKey:"mid",treeNodeParentKey:"pid",showLine:true,root:isRoot:true,nodes:[]}}.setting, varprivilegeDate=mid:pid:isParent: name:'技術(shù)設(shè)施 varprivilegeDate=mid:pid:isParent: name:'技術(shù)設(shè)施 { }]},mid:pid:name技術(shù)資料圖紙管理 isParent:true,{ }](6)functionfunction{ { ontextPath}}else{ ontextPath}}change.jsphome.jsphome.jsp通過框架加載change.jspchange.jspparenthome.jsp中的(7)function{ function{ { }else { }} { }else { }}}}functionwindow}}functionwindow}使用DIV控制數(shù)據(jù)的隱藏和顯actingIndex.jsp中添加功能:js<link<linkhref="${pageContext<scriptlanguage="javascript"src="${pageContext ontextPath<tablecellspacing="0"cellpadding="1"rules="all"bordercolor="gray"border="1"id="DataGrid1"style="BORDER-RIGHT:gray1pxsolid;BORDER-TOP:gray1pxsolid;BORDER-LEFT:gray1pxsolid;WIDTH:100%;WORD-BREAK:break-all;BORDER-BOTTOM:gray1pxsolid;BORDER-COLLAPSE:collapse;BACKGROUND-COLOR:#f5fafe;WORD-WRAP:break-><tdalign="center"width="40%"height=22 ontextPath/images/tablehead.jpg">站點(diǎn)運(yùn)行<tdalign="center"width="40%"height=22 ontextPath/images/tablehead.jpg">設(shè)備運(yùn)行<tdalign="center"width="20%"height=22 ontextPath/images/tablehead.jpg">創(chuàng)建日期<divid="showInfomation"style="visibility:<tronmouseover="this.style.backgroundColor='white'"onmouseout="this.style.backgroundColor='#F5FAFE';"><tdstyle="HEIGHT:22px"align="center"<divclass="scrollStyle"align="left"onmouseover="showInfoWithPanel(this)"onmouseout="hiddenInfoPanel(this)"<s:property<s:property<tdstyle="HEIGHT:22px"align="center"<divclass="scrollStyle"align="left"onmouseover="showInfoWithPanel(this)"onmouseout="hiddenInfoPanel(this)"<s:property<tdstyle="HEIGHT:22px"align="center"<s:datename="createDate"format="yyyy-MM-dd控制文本域的輸入字?jǐn)?shù)第一步:在actingIndex.jsp<script<scriptlanguage="javascript"src="${pageContextontextPath <tdclass="ta_01"align="centerbgcolor="#f5fafe"width="15%"><tdclass="ta_01"bgcolor="#ffffff"style="word-break:break-<s:textareaname="stationRun"id="stationRun"cssStyle="width:500px;height:160px;padding:1;FONT-FAMILY:宋體;FONT-SIZE:9pt"<tdclass="ta_01"align="centerbgcolor="#f5fafe"width="15%"><tdclass="ta_01"bgcolor="#ffffff"style="word-break:break-padding:1;FONT-FAMILY:宋體;FONT-SIZE:9pt"jsfunctionfunctionvarstationRun=newBs_LimitedTextarea('stationRun',2500);stationRlineCssStyle="font-family:arial;font-size:11px;color:gray;";vardevRun=newBs_LimitedTextarea('devRun',2500);devRlineCssStyle="font-family:arial;font-size:11px;color:gray;";}}彈出窗口(windo.open()<input<inputstyle="font-size:12px;color:black;height=20;width=80" ontextPath;scriptfunction.js//open//opensizedfunctionopenWindow(sHref,strWidth,strHeight){varstrLeft=(screen.availWidth-strWidth)/2;varstrTop=(screen.availHeight-strHeight)/2;varstrRef="";varopenerobj=window.open(sHref,'newwin',strRef,false);}關(guān)閉窗口functionfunction}opener可以調(diào)用父頁面的窗口對象,其中actingIndex.jsp(父頁面)exportExcel.jsp(子頁面exportExcel.jsp(子頁面)openeractingIndex.jsp中的對象3:FCK舊版本:FCKfckTestmyeclipse下,發(fā)布項目,并運(yùn)行fckTest的項目。fckEditmyeclipsefckEdit的項目。jseclipsemyeclipsejs,此時會非常浪費(fèi)時間。由于這里使用的CkEditor+CKFinder也使用很多的js,所如果以后大家開發(fā)extjsjqueryeasyUI的項目,要求按照該方法去配置。整合項目的操作步驟:參照【技術(shù)資料\FCK文本編輯器\版本\ckeditor配置資料】中的config.skin'office2003編輯器皮膚樣//config.skin'office2003編輯器皮膚樣////config.toolbar=////config.toolbar=//使用自定義config.toolbar['Source','Preview','-['Undo','Redo','-','Find','Replace','-','SelectAll',['Image','Flash','Table','HorizontalRule','S ['Bold','Italic','Underline','-','Subscript',['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Format','Font', ize','ShowBlocks','-',定義編輯器顯示的效果4:js1:文件上傳、(IO流2:數(shù)據(jù)的導(dǎo)入、導(dǎo)出(IO流4:數(shù)5:js123:系統(tǒng)(產(chǎn)生報告…,js三:項目第三天(數(shù)據(jù)字典2:hqlsqlStringStringhql="SELECTDISTINCTo.keywordFROMElecSystemDDLList<Object>list=StringStringhql="SELECTDISTINCTo.keyword,o.ddlNameFROMElecSystemDDLList<Object[]>list=StringStringhql="SELECTo,o.ddlNameFROMElecSystemDDLList<Object[]>list= Stringhql="SELECToFROMElecSystemDDL ecSystemDDL>list=(5)如果是hqlhqlFROMFROMElecSystemDDLecSystemDDL>list=3:頁面使用select進(jìn)行遍歷 <option<s:iteratorvalue="#request.list"<optionvalue="<s:property<s:property<s:select<s:selectlist="#request.list"name="keyword"id="keyword"listKey="keyword"listValue="keyword"headerKey="jerrynew"headerValue=""cssClass="bg"cssStyle="width:180px"Jsfunctionfunctionvartb1=vartempRow$("#dictTbltr").size();//獲取表格的行數(shù)var$tdNum=$("<tdalign='center'></td>");$tdNumvar$tdName=$("<td$tdName.html("<inputname=\"itemname\"type=\"text\"id=\""+tempRow+"\"size=\"45\"varvar$tdDel=$("<td$tdDelhtml("<ahref='javascript:delTableRow(\""+tempRow+"\")'><imgsrc=${pageContextreq ontextPath}/images/delete.gifwidth=15height=14border=0//創(chuàng)建tr,將3個td放置到trvar$tr=}functionvartb1=$("#dictTbl");vartempRow$("#dictTbltr").size();//獲取表格的行數(shù)if(tempRow>rowNum){//獲取刪除行的id指定的對象,例如:<inputname=\"itemnametype=\"textid=\""+tempRow+"\"size=\"45\"maxlength=25>for(i=(parseInt(rowNum)+1);i<tempRow;i++){ $("#"+i).parent()next().html("<ahref='javascript:delTableRow(\""+(i-1)+"\")'><imgsrc=${pageContextreq ontextPath}/images/delete.gifwidth=15height=14border=0}}}Jspborder="1"style="BORDER-RIGHT:gray1pxsolid;BORDER-TOP:gray1pxsolid;BORDER-LEFT:gray1pxsolid;WIDTH:100%;WORD-BREAK:break-all;BORDER-BOTTOM:gray1pxsolid;BORDER-BACKGROUND-COLOR:#f5fafe;WORD-WRAP:break-<table cellpadding="1"rules="all"><tdclass="ta_01"align="center"width="20%"height=22 ontextPath}/images/tablehead.jpg"><tdclass="ta_01"align="center"width="60%"height=22 ontextPath/images/tablehead.jpg">名稱<tdclass="ta_01"align="center"width="20%"height=22 ontextPath/images/tablehead.jpg">刪除<tdclass="ta_01"align="center"<tdclass="ta_01"align="center"<inputname="itemname"type="text"size="45"<tdclass="ta_01"align="center"在使用 實(shí)現(xiàn)表格添加行和刪除行的時候 獲取頁面填寫的值,此時是一Ajax操作 對象:xmlreq=new ontextPath jsontextPathpub.jsvarvarreq=varhandlerFunction=Pub.getReadyStateHandler(req,req.onreadystatechange= req.open("POST",action, varstr=Pub.getParams2Str(sForm);}*創(chuàng)建ajax引*創(chuàng)建ajax引Pub.newXMLHttpRequest=functionnewXMLHttpRequest()varxmlreq=if(window.XMLHttpRequest){xmlreq=newXMLHttpRequest();}elseif(window.ActiveXObject)tryxmlreq=new}catch(e1)tryxmlreqxmlreq=new}catch(e2)}}}return}*@paramsForm:傳遞表單Form1*@paramsForm:傳遞表單Form1Pub.getParams2Str=functionvartryvar ifreturnvarfor(varfld=0;fld<objForm.elements.length;fld++){elt=objForm.elements[fld];strDiv=strDiv+strDiv=strDiv+}}catch(ex)return}return}*@paramreq:@parameleid:表單Form2@returnsPub.getReadyStateHandler=functiongetReadyStateHandler(req,eleid,responseXmlHandler){returnfunction() if(req.readyState==4) 果if(req.status==200) }elsealert("HTTPerror:return}}}方法五:將返回的結(jié)果dictionaryEdit.jsp,并放置到dictionaryIndex.jsp的Form2@paramdata@paramdata:服務(wù)器返回的結(jié)@parameleid:表單Form2Pub.handleResponse=functionvarele ele.innerHTML=data;}6:DOMfunctionfunction{var{if(str.charAt(i)!=""&&str.charAt(i)!="}}return}function{var{if(str.charAt(i)!="}return}function{return} return}了解:springc3p0,大家只要會配置即可,進(jìn)度條(百分比)四:項目第四天(用戶管理3:jqueryajaxstrutsjson<packagename="system"namespace="/system"extends="json-<!--默認(rèn)將棧頂?shù)膶ο?,轉(zhuǎn)換成<!--默認(rèn)將棧頂?shù)膶ο?,轉(zhuǎn)換成json對象,如果棧頂是一個集合,轉(zhuǎn)換成json數(shù)組<resultname="findJctUnit"functionfindJctUnit(o){varfunctionfindJctUnit(o){varjct=$("#jctUnitIDoption")remove();if(data!=null&&for(varvarddlCode=data[i].ddlCode;varddlName=data[i].ddlName;var$option=}}}ActionList集合放置到棧頂,struts2publicpublicStringStringjctID=elecUser.getJctID(); ecSystemDDL>listreturn}ListListjson化。Listjsonjson化<!--默認(rèn)將棧頂?shù)膶ο?,轉(zhuǎn)換成json對象,如果棧頂是一個集<!--默認(rèn)將棧頂?shù)膶ο?,轉(zhuǎn)換成json對象,如果棧頂是一個集合,轉(zhuǎn)換成json數(shù)組<resultname="findJctUnit"<param4:jqueryajax<packagename="system"namespace="/system"extends="json-<result<resultname="checkUser"的數(shù)據(jù)結(jié)果<param對象中的某個屬性被json<param<paramfunctioncheckUser(o){varlogonName=$(o).val();$("#check").html("<fontcolor='red'>登錄名不能為空</font>");ofocus();}else$(o)[0]}}}第四步:在ActionStringmessagepublicpublicStringStringlogonName=elecUser.getLogonName(); Stringmessage=returnreturn}第五步:在ServicemessagepublicpublicStringcheckUserByLogonName(StringlogonName){Stringmessage="";Stringcondition="ando.logonName=?";Object[]params={logonName}; if(list!=null&&list.size()>0){findCollectionByCmessage="2";}message=}}message=}return} { returnfalse;}}Jsfunctionfunction{varpatternif(pattern.test(strNumber))returnreturnreturn} 文件下傳publicpublicclassFileUploadUtils*完成文件上 開publicstaticStringfileUploadReturnPath(Fileupload,StringuploadFileName,Stringmodel){Stringbasepath=Stringdatepath=DateUtils.dateToString(newStringperfixStringStringfilename=StringmodelPath=basepath+datepath+model;FiledateFile=new}FiledestFile=newreturn"/upload"+}publicstaticvoidmain(String[]args)throwsException FilesrcFile=newFiledestFile=new//FileUtils.copyFile(srcFile,booleanflag=srcFile.renameTo(destFile);}}<form<form<sfilename="upload"id="upload"cssStyle="width:450px;"></s:file>privateprivateFile[]privateString[]privateString[]<sfilename="upload"id="upload"<sfilename="upload"id="upload"cssStyle="width:450px;"></s:file>struts2提供的文件ActionpublicpublicStringdownload()throwsStringid=elecUser.getFileID();ElecUserFileelecUserFile=Stringpath= StringStringname=//處理中文問題,或者使用:nameURLEncoder.encode(name,UTF-8");name=newString(name.getBytes("gbk"),"iso-8859-1"); InputStreamin=newFileInputStream(newOutputStreamout=for(intb=-1;(b=in.read())!=-1;){}return}struts2提供的文件InputStream類型的屬性,用來存放文件的輸入流struts.xmlinputName的值一致。publicStringdownload()throwspublicStringdownload()throwsException{Stringid=elecUser.getFileID();ElecUserFileelecUserFile=StringStringpath= Stringname=//處理中文問題,或者使用:nameURLEncoder.encode(name,UTF-8");name=newString(name.getBytes("gbk"),"iso-8859-1");request.setAttribute("filename",name);InputStreamin=newFileInputStream(newreturn"fileSuccess";}8:使用md5的加理用戶第一步:導(dǎo)入工具類,放置到cn..elec.util包privateprivatevoidmd5Password(ElecUserelecUser)StringlogonPwd=Stringmd5LogonPwd=logonPwd="123";}Stringpassword= 與輸入 ifif(StringUtils.isNotBlank(password)&&password.equals(logonPwd)){md5LogonPwd=logonPwd;} 加MD5keyBeanmd5keyBean=newMD5keyBean();md5LogonPwd=md5keyBean.getkeyBeanofStr(logonPwd);}} <s:hiddenname="password"jquery的ajax完成業(yè)務(wù)操作,文件的上傳和了解知識:md5的加密五:項目第五天(角色管理角色和權(quán)限的關(guān)系:不使用JsfunctioncheckAllOper(oper){}functiongoSelect(id){vararray===//}//}}}var$check=varflag=flag=true;returnfalse;}}}}}JspbgColor=bgColor="#f5fafe"border="0"<tdclass="ta_01"colspan=2align="left"width="100%"全選/全不選<inputtype="checkbox"<tablecellspacing="0"align="center"width="100%"cellpadding="1"rules="all"bordercolor="gray"border="1"style="BORDER-RIGHT:gray1pxsolid;BORDER-TOP:gray1pxsolid;BORDER-LEFT:gray1pxsolid;WORD-BREAK:break-all;BORDER-BOTTOM:gray1pxsolid;BORDER-COLLAPSE:collapse;BACKGROUND-COLOR:#f5fafe;WORD-WRAP:break-<s:iftest="#request.popedomList!=null&&<s:setvalue="%{'1'}"scope="request"<s:iteratorvalue="#request.popedomList"<s:if<s:if<s:setvalue="%{'1'}"scope="request"<tronmouseover="this.style.backgroundColor='white'"onmouseout="this.style.backgroundColor='#F5FAFE';"><tdclass="ta_01"align="left"width="18%"height="22"background="../images/tablehead.jpg"><s:if<inputtype="checkbox"name="selectoper"id="<s:propertyvalue="#popedom.mid"/>_<s:propertyvalue="#popedom.mid"/>"value="<s:propertyvalue="#popedom.pid"/>_<s:propertyvalue="#popedom.mid"/>"onClick='goSelect(this.id)'checked="checked"><inputtype="checkbox"name="selectoper"id="<s:propertyvalue="#popedom.mid"/>_<s:propertyvalue="#popedom.mid"/>"value="<s:propertyvalue="#popedom.pid"/>_<s:propertyvalue="#popedom.mid"/>"onClick='goSelect(this.id)'><s:property<s:if<tdclass="ta_01"align="left"width="82%"height="22">s:setvalue="%{'2'}"scope="request"var="flag"></s:set><s:if<inputtype="checkbox"name="selectoper"value=value="#popedom.pid"/>_<s:propertyvalue="#popedom.mid"/>"value="<s:propertyvalue="#popedom.pid"/>_<s:propertyvalue="#popedom.mid"/>"onClick='goSelect(this.id)'checked="checked"><inputtype="checkbox"name="selectoper"id="<s:propertyvalue="#popedom.pid"/>_<s:propertyvalue="#popedom.mid"/>"value="<s:propertyvalue="#popedom.pid"/>_<s:propertyvalue="#popedom.mid"/>"onClick='goSelect(this.id)'><s:property<inputtype="hidden"name="roleID"在使用<inputtype=”checkbox”>進(jìn)行保存的時候,獲取頁面選中復(fù)選框value的屬性值,此時是一個String類型的數(shù)組對象,可以采用遍歷數(shù)組的方式,保存數(shù)據(jù)。<setname="elecRoles"<setname="elecRoles"table="elec_user_role"inverse="true"<column<column<many-to-many.ElecRole"elec_user_role的數(shù)據(jù)可以刪除,但是角色表中數(shù)據(jù)也會被刪除,這樣顯說明,由角色一端負(fù)責(zé)關(guān)聯(lián)關(guān)系:也就是說角色可以操作用戶,用戶不能操作角色。重點(diǎn):角色管理的開發(fā),多和多的關(guān)聯(lián)關(guān)系(hibernate,不使用六:項目第六天(系統(tǒng)登錄1:struts2的validator校驗(yàn)(校驗(yàn)Js校驗(yàn)(前臺校驗(yàn)Ajax校驗(yàn) 校驗(yàn)Struts2的validator校驗(yàn) 校驗(yàn) 校第一步:在Actionthis.addFieldError("error用戶名輸入有誤!");return"error";}<action<actionAction_*"Action"<resultname="error">/WEB- /index.jsp中,定義:使用struts2的,輸出錯誤信息:src2template/simplefielderror.ftl的文件放置到該文件夾下,此時啟動的時候,就會覆蓋struts包的下加載的內(nèi)容<#list<#listeKeysas<#assigneValue=<#listeValueas<font<#if2:hibernatepublicpublicElecUserfindUserByLogonName(Stringname){Stringcondition="ando.logonName=?";Object[]params={name}; ecUser>list=elecUserDao.findCollectionByConditionNoPage(condition,params,null);ElecUserelecUser=null;if(list!=null&&list.size()>0){elecUser=}* returnelecUser;}方案二:在Service層的方法中(Session關(guān)閉之前publicpublicElecUserfindUserByLogonName(Stringname){Stringcondition="ando.logonName=?";Object[]params={name}; ecUser>list=elecUserDao.findCollectionByConditionNoPage(condition,params,null);ElecUserelecUser=null;if(list!=null&&list.size()>0){elecUser=}* returnelecUser;}}<setname="elecRoles"table="elec_user_role"<setname="elecRoles"table="elec_user_role"inverse="true"<column<many-to-many.ElecRole"建議項目開發(fā)中不要在.hbm.xmllazy=false,這樣如果表關(guān)聯(lián)比較多,不需要springOpenSessionInViewFilterweb容器中添加該過濾器web.xml中添加:的懶加載問題 1:事務(wù)提1:事務(wù)提交:spring提供 式事務(wù)控制,仍然在業(yè)務(wù)層的方法進(jìn)行處理,方執(zhí)行完畢后,事務(wù)會自動提交,如果出現(xiàn)異常,事務(wù)就會回滾。但是它延遲了執(zhí)行完畢后,事務(wù)會自動提交,如果出現(xiàn)異常,事務(wù)就會回滾。但是它延遲了Session。OpenSessionInViewFilter,這樣Session不關(guān)閉,另一個Session就無法,連接不第一步:index.jsp<tdwidth="100"><img ontextPath}/images/check.jpg"width="75"<inputtype="text"name="checkNumber"id="checkNumber"value=""maxlength="4"size="7"><imgsrc="${pageContext.req name="imageNumber"id="imageNumber"style="cursor:hand"title="點(diǎn)擊可更換 height="20"onclick="checkNumberImage()"/>JsfunctionfunctionvarimageNumber imageNumber.srcimageNumber.src=}RandomRandomrandom=newRandom();StringsRand="";for(inti=0;i<4;i++)Stringrand=String.valueOf(random.nextInt(10));sRand+=rand;}將認(rèn)證碼存入tryImageIO.write(image,"JPEG",}catch(Exceptione)}第二步:在Action中進(jìn)行校驗(yàn),創(chuàng)建LoginUtilspublicpublicclassLogonUtilspublicstaticbooleancheckNumber(HttpServletRequestrequest)StringcheckNumber=returnfalse;} 的StringCHECK_NUMBER_KEY=returnfalse;}return}}第一步:index.sp<tdwidth="100"><imgontextPath}/images/remeber.jpg"<inputtype="checkbox"name="remeberMe"id="remeberMe"publicpublicclassLogonUtilspublicstaticvoidremeberMe(Stringname,Stringpassword,HttpServletRequestrequest,HttpServletResponseresponse){ = = StringremeberMe=if(remeberMe!=null&&remeberMe.equals("yes")){ } }}}Stringname="";Stringpassword="";Stringchecked=""; s= s!=null:name= checked="checked";} password= }}}index.jsp中的數(shù)據(jù),jspjavajavajspjspjava代碼,然后再執(zhí)行。效率會降java代碼抽取出去呢?publicpublicclassSystemFilterimplementsFilterpublicvoidinit(FilterConfigconfig)throwsServletException} publicvoiddoFilter(ServletRequestreq,ServletResponseres,FilterChainchain)throwsIOException,ServletException{HttpServletRequestrequest=(HttpServletRequest)HttpServletResponseresponse=(HttpServletResponse) Stringpath= chain.doFilter(request,}publicvoiddestroy()} privatevoidforwordIndexPage(Stringpath,HttpServletRequestrequest){if(path!=null&&path.equals("/index.jsp")){Stringname="";Stringpassword="";Stringchecked=""; s=request.get s!=null&& name= try{name=URLDecoder.decode(name,"UTF-}catch(UnsupportedEncodingExceptione){}checked=} password= }}}request.setAttribute("name",name);request.setAttribute("password",password);request.setAttribute("checked",checked);}}}}自定義過濾器,要求添加到struts2自定義過濾器,要求添加到struts2 測試后:發(fā)現(xiàn)問題:如果name中存在中文,此時中文字符是不能存放到對象中,使用HttpResponse對象添加會拋出異常。在過濾器SystemFiltername:tryname=在過濾器SystemFiltername:tryname=URLEncoder.encode(name,"UTF-}catch(UnsupportedEncodingExceptione){} = = name= tryname=URLDecoder.decode(name,"UTF-}catch(UnsupportedEncodingExceptione){}checked=}5:jqueryztree插件的使用(完成動態(tài)加載樹型結(jié)構(gòu)left.jsp<<scriptontextPath}/script/jquery-<scriptontextPath}/script/jquery-ztree-<script ontextPath <linktype="text/css"ontextPath.css"Left.jsp中使用<TABLE<TABLEborder=0<TDwidth=340pxalign=center<div<ul Tree"class="tree".js ={setting:{isSimpleData:true,treeNodeKey:"mid",treeNodeParentKey:"pid",showLine:true,root:isRoot:true,nodes:[]} .setting,}publicStringpublicStringStringpopedom=(String) ecPopedom>list=return }publicecPopedom>findPopedomListByUser(Stringpopedom)publicecPopedom>findPopedomListByUser(Stringpopedom)Stringcondition="ando.midIN('"+popedom.replace("@","','")+"')AND =?";Object[]params=Map<String,String>orderby=newLinkedHashMap<String,String>();orderby.put("o.mid","asc"); ecPopedom>list=elecPopedomDao.findCollectionByConditionNoPage(condition,params,orderby);return}將集合壓入到棧頂,集合返回頁面的時候,轉(zhuǎn)換成json的形將集合壓入到棧頂,集合返回頁面的時候,轉(zhuǎn)換成json的形式<result "精確到Session的權(quán)限控制(判斷Session是否存在publicclassSystemFilterimplementsFilterpublicclassSystemFilterimplementsFilterList<StringlistnewArrayList<String>();publicvoidinit(FilterConfigconfig)throwsServletException } publicvoiddoFilter(ServletRequestreq,ServletResponseres,FilterChainchain)throwsIOException,ServletException{HttpServletRequestrequest=(HttpServletRequest)req;HttpServletResponseresponse=(HttpServletResponse)res; Stringpath= chain.doFilter(request,response);}ElecUserelecUser=chain.doFilter(request,response);}}publicvoiddestroy()}} privatevoidforwordIndexPage(Stringpath,HttpServletRequestrequest)if(path!=null&&path.equals("/index.jsp")){Stringname="";Stringpassword="";Stringchecked=""; s= s!=null:name tryname=URLDecoder.decode(name,"UTF-}catch(UnsupportedEncodingExceptione){}checked=} password= }}}request.setAttribute("name",name);request.setAttribute("password",password);request.setAttribute("checked",checked);}}}自定義過濾器,要求添加到struts2自定義過濾器,要求添加到struts2 問題:不夠友好,,最好提示【操作,系統(tǒng)將會5秒后跳轉(zhuǎn)到登錄頁面】init2 在doFilter的方法重定向到vari=6;vart;function要清除掉setInterval()ontextPathi=i-1//秒數(shù)減少timer層 =}}//showTimer()t=window.setInterval(showTimer,1000);注意:SessionSessionSession壓力大,系10分鐘如果不操作系統(tǒng),將Session在過濾器中獲取登錄后存放的SessionSession不為空,則放行,即可以操作定義的業(yè)務(wù)功能,如果Session為空,則跳轉(zhuǎn)到登錄頁面???的系統(tǒng)必須要存在添加異常處理,見【技術(shù)資料\自定義器(實(shí)現(xiàn)異常處理+細(xì)顆粒權(quán)限控制)\異常處理】中的《struts2的器實(shí)現(xiàn)異常處理.doc》使用struts2 ntercept()方法定義try…catch異result=actioninvocation.invoke();returnresult;resultreturn"errorMsg";跳轉(zhuǎn)到錯誤頁面。9:細(xì)顆粒權(quán)限控制(使用struts2的器中的《struts2的器實(shí)現(xiàn)細(xì)顆粒度權(quán)限控制.doc》struts2么不從Sessionmidmidstruts2么不從Sessionmidmid Session,使用struts2 pid(mid=””,pid=””在struts2 pid重點(diǎn):登錄操作,項目中校驗(yàn)和前臺校驗(yàn),hibernate的懶加載處理了解:,記住我1:使用webservice發(fā)布系統(tǒng)元數(shù)據(jù),調(diào)用的過操作步驟【技術(shù)資料\webservice技術(shù)\axis的jar包中《axis發(fā)布, 第一步:使用服務(wù)器端提供的接口,生成.wsdl文件第二步:使用.wsdl文件,在電力系統(tǒng)中生成服務(wù)器端的代碼第三步:使用.wsdl文件(()webserviceweb容器啟動的時候( 使用的時候只需要從application對象中獲取即可 2:hibernate的二級緩存 hibernate的二級緩存優(yōu)化。需要引入三個jar包在hibernate需要引入三個jar包在hibernate下能找到在 下能找 <?xml<?xmlversion="1.0"encoding="UTF-<!DOCTYPEhibernate-configuration"-//Hibernate/HibernateConfigurationDTD3.0//EN"開啟二級緩存提供二級緩存的供應(yīng)商啟用查詢緩存<property<!--<!--加 文件-- <class-cacheusage="read-write" 第三步:在DAOhqlsetCacheable(true)publicpublicList<T>findCollectionByConditionNoPageWithCache(StringfinalObject[]params,Map<String,String>orderby)Stringhql="SELECToFROM"+entityClass.getSimpleName()+"oWHERE1=1";StringorderByHql=this.initOrderByHql(orderby);finalStringfinalHql=hql+condition+List<T>list=HibernateCallback()publicnHibernate(SessionthrowsHibernateException,SQLException{Queryquery=session.createQuery(finalHql);if(params!=null&¶ms.length>0){for(inti=0;i<params.length;i++){query.setParameter(i,params[i]);}}returnquer

溫馨提示

  • 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

提交評論