DROP TABLE IF EXISTS `cost`;
create table cost(
cost_id int(4) auto_increment,
name varchar(50) not null,
base_duration int(11),
base_cost double(7,2),
unit_cost double(7,4),
status char(1),
descr varchar(100),
creatime datetime default now(),
startime datetime,
cost_type char(1),
constraint cost_id_pk primary key(cost_id)
);
insert into cost values (null,'5.9元套餐',20,5.9,0.4,0,'5.9元20小时/月,超出部分0.4元/时',default,default,null);
insert into cost values (null,'6.9元套餐',40,6.9,0.3,0,'6.9元40小时/月,超出部分0.3元/时',default,default,null);
insert into cost values (null,'8.5元套餐',100,8.5,0.2,0,'8.5元100小时/月,超出部分0.2元/时',default,default,null);
insert into cost values (null,'10.5元套餐',200,10.5,0.1,0,'10.5元200小时/月,超出部分0.1元/时',default,default,null);
insert into cost values (null,'计时收费',null,null,0.5,0,'0.5元/时,不使用不收费',default,default,null);
insert into cost values (null,'包月',null,20,null,0,'每月20元,不限制使用时间',default,default,null);
insert into cost values (null,'mm',10,5,null,0,'',default,default,null);
insert into cost values (null,'nn',10,7,null,0,'',default,default,null);
insert into cost values (null,'qq',10,4,null,0,'',default,default,null);
package entity;
public class Cost implements Serializable {
private Integer costId;
private String name;
private Integer baseDuration;
private Double baseCost;
private Double unitCost;
private String status;
private String descr;
private Timestamp creatime;
private Timestamp startime;
private String costType;
}
package dao;
import java.util.List;
import entity.Cost;
public interface CostDao {
List findAll();
}
public interface CostService {
List findAll();
}
@Service("CostService")
public class CostServiceImpl implements CostService {
@Resource
private CostDao costDao;
public List findAll() {
return costDao.findAll();
}
}
@Controller
@RequestMapping("/cost")
public class CostController {
@Resource
private CostService costService;
@RequestMapping("/find.do")
public String find(ModelMap model){
List list = costService.findAll();
model.addAttribute("costs",list);
return "cost/cost_list";
}
}
<%@page pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
达内-NetCTOSS