课件课后练习代码经典案例_第1页
课件课后练习代码经典案例_第2页
课件课后练习代码经典案例_第3页
课件课后练习代码经典案例_第4页
课件课后练习代码经典案例_第5页
已阅读5页,还剩56页未读 继续免费阅读

下载本文档

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

文档简介

JavaStruts NETCTOSS资费列表显 请Struts2_corejar.zip(Struts2的Jar包),建议使用struts2.18版本;不要使用拷贝Struts2的Jar包到WEB-INF/lib/下,基本功能jar包5个(2.1.8)。图-<?xmlversion="1.0"encoding="UTF-<web-app"h<filter-><!--/*-</filter-</web->新建页面<%@pagepageEncoding="utf-<form e.action"<inputname="name"type="text"<inputvalue="提交"type="submit"新建页 <%@pagepageEncoding="utf-e,新 packagepublicclasseActionprivateStringpublicStringexecute() System.out.println("name:"+if{returnreturnpublicStringgetName(){returnpublicvoidsetName(Stringname){=在Jsp页面<inputname=”name”type=”text”/>在action中会自动给属性privateStringnamename对应的getterAction中属性privateStringname; <?xmlversion="1.0"encoding="UTF-<!DOCTYPEstruts"-//ApacheSoftwareFoundation//DTDStrutsConfiguration"<packageoworld"extends="struts-<action <result<result 继承的包名,一般继承Su默认提供的u-dfaul包,该包中定义了很多Su2应用必须的组件(比如:器);该ackae的位置在u-c-ja/u-dfaulm文件中 e.action e.action publicString <result>1)所对应的

图-

图-<?xmlversion="1.0"encoding="UTF-<web-app"h<filter-<filter-><url-pattern>/*</url-pattern><!--/*表示所有的请求都要经过该过滤器</filter-</web-><%@pagepageEncoding="utf-<form e.action"<inputname="name"type="text"<inputvalue="提交"type="submit"<%@pagepageEncoding="utf-e,packagepublicclasseActionprivateStringpublicStringexecute(){System.out.println("name:"+if{returnreturnpublicStringgetName(){returnpublicvoidsetName(Stringname){=<?xmlversion="1.0"encoding="UTF-<!DOCTYPEstruts"-//ApacheSoftwareFoundation//DTDStrutsConfiguration"<packageoworld"extends="struts-<action<result<result直接图- 图-修改<?xmlversion="1.0"encoding="UTF-<!DOCTYPEstruts"-//ApacheSoftwareFoundation//DTDStrutsConfiguration"<packagename=" oworld"extends="struts-default"<action<action</package>图-图-图-CREATETABLE NUMBER(4)CONSTRAINTCOST_ID_PKPRIMARY NOT CHAR(1)CONSTRAINTCHECK(STATUSIN DATEDEFAULTSYSDATE INSERTINTOCOSTVALUES(1,'5.9元套餐',20,5.9,0.4,0,'5.9元20INSERTINTOCOSTVALUES(2,'6.9元套餐',40,6.9,0.3,0,'6.9元40INSERTINTOCOSTVALUES(3,'8.5元套餐',100,8.5,0.2,0,'8.5元100INSERTINTOCOSTVALUES(4,'10.5元套餐',200,10.5,0.1,0,'10.5元200INSERTINTOCOSTVALUES(5,'计时',null,null,0.5,0,'0.5元/时,不使用INSERTINTOCOSTVALUES(6,'包月',null,20,null,0,'每月20 publicclassConnectionUtilsprivatestaticStringprivatestaticStringprivatestaticStringprivatestaticStringprivatestaticThreadLocal<Connection>tl=newstatictryPropertiesprops=newuser=password=url=driver=}catch(Exceptione)thrownewRuntimeException("数据库驱动加载错误", publicstaticConnectionopenConnection()throws{Connectioncon=if(con==null)con=DriverManager.getConnection(url,user,}return}publicstaticvoidcloseConnection()Connectioncon=if(con!=null)try}catch(SQLExceptione) }publicstaticvoidmain(String[]{Connectioncon=}}创建实体类

图-publicclassFeeprivateIntegerid;//资费privateStringfeeName;//资费名称privateIntegerbaseDuration;//包 privateFloatbaseCost;privateFloatunitCostprivateStringstatus//0:开通;1:暂停;privateStringdescr;//资费信息说明privateStringcreateTime;//创建日期privateStringstartTimepublicstaticFeetoFee(ResultSetrs)throws{Feefee=newFee();return publicIntegergetId()return}publicvoidsetId(Integerid)this.id=}publicStringgetFeeName()return}publicvoidsetFeeName(String{this.feeName=}publicIntegergetBaseDuration()return}publicvoidsetBaseDuration(Integer{this.baseDuration=}publicFloatgetBaseCost()return}publicpublicvoidsetBaseCost(FloatbaseCost)this.baseCost=}publicFloatgetUnitCost()return}publicvoid{this.unitCost=}publicStringgetStatus()return}publicvoidstatus)this.status=}publicStringgetDescr()return}publicvoidsetDescr(Stringdescr)this.descr=}publicStringgetCreateTime()return}publicvoidsetCreateTime(String{this.createTime=}publicStringgetStartTime()return publicvoidsetStartTime(StringstartTime)this.startTime=}}publicclassFeeDAOprivatestaticfinalStringfindAll="selectID,NAME,BASE_DURATIOpublicList<Fee>findAll()Connectioncon=PreparedStatementstmt=ResultSetrs=trycon=stmt=rs=List<Fee>list=newwhile(rs.next())Feefee=new return}catch(Exceptione)thrownew}finally{}}publicclassFeeListActionList<Fee>feeList=null;publicList<Fee>getFeeList(){returnpublicvoidsetFeeList(List<Fee>{this.feeList=publicStringFeeDAOfeeDAO=newFeeDAO();feeList=feeDAO.findAll();return"success";<?xmlversion="1.0"encoding="UTF-<!DOCTYPEstruts"-//ApacheSoftwareFoundation//DTDStrutsConfiguration"<packageoworld"extends="struts-default"<action配置<?xmlversion="1.0"encoding="UTF-<web-appversion="2.5"xmlns="h h>></web-拷贝netctoss项目中的样式表和到工程中,放置在如图-8所示的images和styles文件夹<%@pagelanguage="java"pageEncoding="UTF-<%@taglib/jsp/jstl/core"<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN".<html<metahttp-equiv="Content-Type"content="text/html;charset=utf-<linktype="text/css"rel="stylesheet"media="all"<linktype="text/css"rel="stylesheet"media="all"<!--Logo<div<imgsrc="../images/logo.png"alt="logo"<ahref="#">[<!--Logo<!--导航区域开始--><div<ul <li><ahref="../index.html"<li><ahref="../role/role_list.html"<li><ahref="../admin/admin_list.html"<li><ahref="../fee/fee_list.html"<li><ahref="../account/account_list.html"<li><ahref="../service/service_list.html"<li><ahref="../bill/bill_list.html"<li><ahref="../report/report_list.html"<li><ahref="../user/user_info.html"<li><ahref="../user/user_modi_pwd.html"<!--导航区域结束--><!--主要区域开始--><div<formaction=""<!--排序--><div<input<input<input<inputtype="button"value="增加"class="btn_add"<divid="operate_result_info"<imgsrc="../images/close.png"<div<table<th>资费<thclass="width100">资费名称<th>基本时长<th>基本费用<th>单位费用<th>创建时间<th>开通时间<thclass="width50">状态<th<c:forEachitems="${feeList}"<td>${fee.baseDuration}小时<td>${fee.baseCost}元<td>${fee.unitCost}元/小时<c:iftest="${fee.status==0}"<c:iftest="${fee.status==1}"<c:iftest="${fee.status==2}"<c:iftest="${fee.status!=0&&<inputtype="button"value="启用"<inputtype="button"value="修改"<inputtype="button"value="删除"<p>业务说明:<br/>1、创建资费时,状态为暂停,记载创建时间;<br/>2、暂停状态下,可修改,可删除;<br/>34<!--分页--><div<ahref="#"><ahref="#"<a<a<a<a<ahref="#"><!--主要区域结束--><div<p>[源 公司图-CREATETABLE NUMBER(4)CONSTRAINTCOST_ID_PKPRIMARY NOT CHAR(1)CONSTRAINTCHECK(STATUSIN DATEDEFAULTSYSDATE INSERTINTOCOSTVALUES(1,'5.9元套餐',20,5.9,0.4,0,'5.9元20INSERTINTOCOSTVALUES(2,'6.9元套餐',40,6.9,0.3,0,'6.9元40INSERTINTOCOSTVALUES(3,'8.5元套餐',100,8.5,0.2,0,'8.5元100INSERTINTOCOSTVALUES(4,'10.5元套餐',200,10.5,0.1,0,'10.5元200INSERTINTOCOSTVALUES(5,'计时',null,null,0.5,0,'0.5元/时,不使用INSERTINTOCOSTVALUES(6,'包月',null,20,null,0,'每月20publicclassConnectionUtilsprivatestaticStringprivatestaticStringprivatestaticStringprivatestaticStringprivatestaticThreadLocal<Connection>tl=newstatictryPropertiesprops=newuser=password=url=driver=}catch(Exceptione)thrownewRuntimeException("数据库驱动加载错误", publicstaticConnectionopenConnection()throwsSQLExceptionConnectioncon=if(con==null)con=DriverManager.getConnection(url,user, return publicstaticvoidcloseConnection()Connectioncon=if(con!=null)try}catch(SQLExceptione)}}}publicstaticvoidmain(String[]throwsExceptionConnectioncon=}}publicclassFeeprivateIntegerid;//资费privateStringfeeName;//资费名称privateIntegerbaseDuration;//包 privateFloatbaseCost;privateFloatunitCostprivateStringstatus//0:开通;1:暂停;privateStringdescr;//资费信息说明privateStringcreateTime;//创建日期privateStringstartTime;publicstaticFeetoFee(ResultSetrs)throwsSQLExceptionFeefee=newreturn publicIntegergetId()return publicvoidsetId(Integerid)this.id= publicStringgetFeeName()return publicvoidsetFeeName(StringfeeName)this.feeName= publicIntegergetBaseDuration()return publicvoidsetBaseDuration(IntegerbaseDuration)this.baseDuration=}}publicFloatgetBaseCost()return}publicvoidsetBaseCost(Floatthis.baseCost=}{publicFloatgetUnitCost()return}publicvoidsetUnitCost(Floatthis.unitCost=}{publicStringgetStatus()return}publicvoidsetStatus(Stringthis.status=}{publicStringgetDescr()return}publicvoidsetDescr(Stringdescr)this.descr=}publicStringgetCreateTime(){returncreateTime; publicvoidsetCreateTime(StringcreateTime)this.createTime= publicStringgetStartTime()return}publicvoidsetStartTime(StringstartTime)this.startTime=}}publicclassFeeDAOprivatestaticfinalStringfindAll="selectID,NAME,BASE_DURATIOpublicList<Fee>findAll()Connectioncon=PreparedStatementstmt=ResultSetrs=trycon=stmt=rs=List<Fee>list=newwhile(rs.next())Feefee=newreturn}catch(Exception{thrownew}publicclassFeeListActionList<Fee>feeList=null;publicList<Fee>getFeeList(){return}publicvoidsetFeeList(List<Fee>feeList){this.feeList=feeList;}publicStringFeeDAOfeeDAO=newFeeDAO();feeList=feeDAO.findAll();return"success";}}<?xmlversion="1.0"encoding="UTF-<!DOCTYPEstruts"-//ApacheSoftwareFoundation//DTDStrutsConfiguration"<packageoworld"extends="struts-default"<action<?xmlversion="1.0"encoding="UTF-<web-appversion="2.5"xmlns="h h<filter->></web-<%@pagelanguage="java"pageEncoding="UTF-<%@taglib/jsp/jstl/core"<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN".<html<metahttp-equiv="Content-Type"content="text/html;charset=utf-<linktype="text/css"rel="stylesheet"media="all"<linktype="text/css"rel="stylesheet"media="all"<!--Logo<div<imgsrc="../images/logo.png"alt="logo"<ahref="#">[<!--Logo<!--导航区域开始--><div<ul <li><ahref="../index.html"<li><ahref="../role/role_list.html"<li><ahref="../admin/admin_list.html"<li><ahref="../fee/fee_list.html"<li><a

温馨提示

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

评论

0/150

提交评论