java 代账_家庭记账本小程序之改(java web基础版五)(示例代码)

实现修改消费账单

1.main_left.jsp中该部分,调用Servlet中的list方法

20190226190510217446.png

2.Servlet中的list方法,调用Dao层的list方法,跳转到list.jsp页面

20190226190510318026.png

3.Dao层的list方法

20190226190510443018.png

4.list.jsp,提交到Servlet的getcoursebyid方法

pageEncoding="UTF-8"%>

Insert title here

.a{

font-size: 20px;

}

Object message = request.getAttribute("message");

if(message!=null && !"".equals(message)){

%>

alert("");

id消费名称消费金额消费日期
${item.id}${item.name}${item.money}${item.date}修改

5.Servlet的getcoursebyid方法,调用Dao层的getCourseById方法,跳转到detail2.jsp

20190226190510580704.png

6.Dao层的getCourseById方法

20190226190510672495.png

7.detail2.jsp,调用Servlet的update方法,

pageEncoding="UTF-8"%>

Insert title here

.a{

margin-top: 20px;

}

.b{

font-size: 20px;

width: 160px;

color: white;

background-color: greenyellow;

}

Object message = request.getAttribute("message");

if(message!=null && !"".equals(message)){

%>

alert("");

消费名称:

消费金额:

消费日期:

修   改

function check() {

var name=document.getElementById("name");

var money=document.getElementById("money");

var date=document.getElementById("date");

if(name.value==‘‘){

alert(‘消费名称为空‘);

name.focus();

return false;

}

if(money.value==‘‘){

alert(‘消费金额为空‘);

money.focus();

return false;

}

if(date.value==‘‘){

alert(‘消费日期为空‘);

date.focus();

return false;

}

}

8.Servlet的update方法,调用Dao层的update方法

20190226190510805299.png

9.Dao层的update方法,实现与数据库的操作,添加成功

20190226190510930291.png

总结:

Servlet?method=list --> Dao?method=list --> list.jsp --> Servlet?method=getcoursebyid --> Dao?method=getCourseById --> detail2.jsp --> Servlet?method=update --> Dao?method=update

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值