使用jsp的model2模型开发购物车(bookstore)
- 搭建开发环境
- 导入开发包:jdbc驱动 (jstl的jar)
- 创建程序所在的在mysql下创建库和表 book : id ,name, author price description
- 编码:
- 开发实体类bean :Book
- 开发dao (创建工具类)
- 开发service
- web层
新建WEB项目
考驱动
创建包
创建表
创建数据库
创建表
添加数据
create database bookstore
use bookstore
create table book(
id int not null primary key auto_increment,
name varchar(20) unique,
author varchar(20),
price double,
desscription varchar(40));
set character_set_client=gb2312;
set character_set_results=gb2312;
insert into book values(1,'java高级','李丹','32.90','很好');
insert into book values(2,'mysql数据库','张三','29.70','很好');
insert into book values(3,'c#技术详解','李四','62.40','一般般');
insert into book values(4,'Xml技术详解','Jack','45.90','很好');
insert into book values(5,'JSP详解','Tom','77.90','很好');
insert into book values(6,'Android开发应用','Daney','56.30','很好');
domin封装实体对象
package www.hbsi.domain;
public class Book {
private int id;
private String name;
private String author;
private double price;
private String desscription;
public Book() {
super();
}
public Book(int id, String name, String author, double price,
String desscription) {
super();
this.id = id;
this.name = name;
this.author = author;
this.price