IT学习知识总结_第1页
IT学习知识总结_第2页
IT学习知识总结_第3页
IT学习知识总结_第4页
IT学习知识总结_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

IT实践报告(论文)报告题目IT学习相关课题详细整理姓名 学 院 中国农业大学专业 学 号 01930493289 导师 中国农业大学2011年7月25日中国农业大学研究生社会实践XML文件及10流读取l.Xml文件的编写//xinl声明//veision版本号encodmg编码方式<?xiiilversion=n1.0Hencoding=uutf-8n?><Smdent> 〃根节点自定义的<stu><pid>l</pid>vpiKime>张H</pname></stu><stu><pid>2</pid><pname>李四</pname></stu></Student>2•文件流读取packagetest;importjava.io.FilelnputStream;importjava.io.FileNotFoundException;importjava.io.IOException;importjava.io.IiiputStream;publicclasstl{/***©paramargs*/publicstaticvoidmain(Strmg[]aigs){//TODOAuto-generatedmethodstub〃打开:输入流//IiiputStreainm=??;//IiiputStreamin=newFileniputStieam(nversion.min);IiiputStreamin=newFileInputStream(Ma.txtH);〃读字节〃新建数组byteb[]=newbvte[300];〃将文件内容读入数组m.read(b);System.out.prmthi(newStiing(b));〃关闭m.clos亡();}catch(FileNotFoundExceptione){//TODOAuto-geneiatedcatchblocke.prmtStackTrace();}catch(IOExceptione){//TODOAuto-geneiatedcatchblocke.prmtStackTrace();}}///////////////packagetest;importjava.io.BufleiedReadei-;importjava.io.FilelnputStream;importjava.io.FileNotFoundException;importjava.io.IOException;importjava.io.IiiputStreaiii;importjava.io.IiiputStreaniReader;publicclasst3{*@paramargs*/publicstaticvoidmain(Strmg[]aigs){//TODOAuto-generatedmethodstub〃打开文件try{IiiputStreamin=newFileInputStream(Mversion.iniH);BufferedReaderreader=newBuffeiedReader(newInputStieaniReader(m));〃逐行读取String11=ieader.readLme();System.ou匚pnntln(l1);〃关闭reader.close();m.closeQ;}catch(FileNotFoundExceptione){//TODOAuto-geneiatedcatchblocke.prmtStackTrace();}catch(IOExceptione){//TODOAuto-geneiatedcatchblocke.prmtStackTrace();}}}3•文件流写入packagetest;importjava.io.FileNotFoundException;importjava.10.FlleOutputStieam;importjava.io.IOException;importjava.10.OutputStream;publicclasst2{/***@paramargs*/publicstaticvoidmain(Strmg[]args){//TODOAuto-generatedmethodstub〃打开文件Outputstreamout=newFileOutputStreain(na.txtH);〃一个字一个字写入byteb[]=newbyte[2];b[0]=65;b[l]=66;out.wiite(b);out.write(H1234567H.getBytes0);〃关闭out.closeQ;}catch(FileNotFoundExceptione){//TODOAuto-geneiatedcatchblocke.prmtStackTrace();}catch(IOExceptione){//TODOAuto-geneiatedcatchblocke.prmtStackTrace();}}}4.XML文件流读取<?xiiilversion=M1.0Mencodmg=nutf-8H?><person><nian><id>l</id><name>^lE当Viiame><addr><country>□本v/country〉<ctiy>犬阪v/ctiy></addr></nian><nian><id>2</id>亡〉猪八戒<addr><country>中国v/country〉<ctiy>高老庄</ctiy></addr></nian><women><id>l</id><name>夏娃Viiame><addr><country>ii国v/country〉<c"y>巴黎v/chy></addr></women><women><id>2</id>嫦娥<addr><country>中国v/country〉<ctiy>小高老庄</ctiy></addr></women></peison>〃第一步导入dom4j.jarjar包packagechaipter5;mipoitjava.10.F1le;mipoitjava.util.List;mipoitofg.dom4j.Document;mipoitofg.dom4j・DocumentException;mipoitofg.dom4j.Element;importorg.dom4j.lo.SAXReader;publicclassT2{/***@paiamargs*/publicstaticvoidmain(Stnng[]args){//TODOAuto-geneiatedmethodstubtiy{〃打开文档Filef=newFile("date.xnil");〃创建解析器SAXReaderxeadei-newSAXReadeiQ;〃解析文件后得到的DOM对象Documentdoc=ieadei\iead(f);〃得到根元素Elementioot=doc.getRootElement();〃得到根元素集合List<Element>list=ioot.elements(nmanH);〃遍历出结果fbi(Elemente:list){System.out.println(e.elementText(nidn)+,7,+e.elemeiitText(nnamen)+M,n);Elementman=e.element("addru)y/创建节点System.out.pimtln(nian.elementText(ncountiyn)+n,n+man.elenieiitText(nctiyn));

}}catch(DocumentExceptione){//TODOAuto-geneiatedcatchblocke.printStackTrace();}}Ajax无刷新页面提交Ajax无刷新页面提交1•普通实现1•普通实现<body>第一页1.表单<br/><fbnnaction=nsecond.jspu><inputtype=Hsubnutnvalue=u提交"/></foim><br/>2.<aluef^Hsecond.jsp?id=0&name=qqu>Hief</a><br/>3.JS无刷新<br/><inputtvpe=ubuttonHvalue=,r无刷新请求"onciick=,fsendRequestOn/><br/><divld-resp^</div><scnpttvpe=Htext?javascnptH>//aleil(window.ActiveXObject);//aleil(window.XMLHttpRequest);--用來判断浏览器差异的两种对象〃符号函数fiuiction$(id){returndocument.getElenientBvId(id);}vaixmllittp;//〃创建浏览器兼容的xnilhttprequest对象functioncieateXMLHttp(){</bodv>//second.jsp页面<%@pagelanguage=ffjavalfimpo^^java.util.*11pageEncoding=ffutf-8,1%><%Stringpath=request.getContextPath();String basePathrequest.getScheme()+ll://n+request.getServerName()+ll:n+request.getServerPort()+path+l7fl;%><!DOCTYPEHTMLPUBLIC“・//W3C〃DTDHTML4.01Transitional//ENf,><html><head><basehref=,,<%=basePath%>,,><title>MyJSP'index.jsp'startingpage</title><metahttp-equiv=llpragma,1content=11no-cache11><metahttp-equiv=11cache-control11content=,,no-cachefl><metahttp-equiv=llexpiresttcontent=,,0ll><metahttp・equiv二"keywords''content=11keyword1^keyword2,keyword311><metahttp・equiv二''description"content二"Thisismypage"〉<!-<linkrel二"stylesheet”type=f,text/cssnhref=nstyles.csst,>~></head><bodv><hl>第二页<%request.setCharacterEncoding(nutf-8n);%>v%=request.getParameter(''id'')%>v%=request.getParameter(''name”)%><%System.out.println(M第二页");%></hl></body></html>2JQuery实现无刷新页面提交<%@pagelanguage=njavaHimport=njava.util.*upageEncoding=uutf-8u%><%Stungpath=request.getContextPathQ;StungbasePath=iequest.getScheme()十n://M+request.getSeiverName()十n:n+request.getSeiveiPort()+path+‘7”;%><!DOCTYPEHTMLPUBLICn-//W3C//DTDHTML4.01Tiansitional//ENn><html><head><baseluef=H<%=basePath%>H><title>MyJSP,mdex.jsp,stailmgpage</title><metahttp-equiv=HpfagmaHcontent=Hno-caclieH><metahttp-equiv=Hcache-contror,content=uno-cachen><metahttp-equiv=nexpiresucontent=H0n><metahttp-equiv=HkeywoidsMcontent=nkewroid1、keywoid2、keywoid3"><metahttp-equiv=Hdescnptionncontent=HTlusismypageH><!导入jqiiery文件><scnpttype=Mtext/javascnptHsrc=Hscnpt/jquery-1.4.2.jsH></scnpt><!_<lmkfel=ustylesheetntvpe=utext/cssnluef=nstyles.cssn>—><body><111>jQuery无刷新<br/><inputtvpe=ubuttonMvalue=njQueiy无刷新请求"onclick=HjqueiyRequest()n/><br/><divid-resp^</div><scnpttype=ntext/javascnptn>〃发送请求functionjqueryRequest(){//uil,data,callback//S.post("second.jspn,null);//$.post(nsecond.jspH,nid=2&iiame=toni役handleResponse);S.post("second・jsp役nid=2&name=tomn,fxinction(v){alert(v);});}〃处理响应functionhandleResponse(data){aleit(data);}</script></hl></bodv></html>//second.jsp页面<%@pagelanguage=ftjavatfimports"java.util•旳pageEncoding=lfutf-811%><%Stringpath=request.getContextPath();String basePathrequest.getScheme()+ll://n+request.getServerName()+l,:n+request.getServe

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论