JSP/JSP 공부

[jsp] jsp_project (DB와 화면까지 연결하기)

congs 2023. 5. 10. 17:40

https://jungeun980906.tistory.com/313 설정에 이어서 프로젝트 생성해보기!

5. domain package 에 ProductVO class생성!

DB의 설정을 참고하여 class의 멤버변수를 작성하자!

package domain;

public class productVO {
	/* create table product(
		pno int not null auto_increment,
		pname varchar(50) not null,
		price int not null,
		regdate datetime default now(),
		madeby varchar(50),
		primary key(pno)
		);
	 * */
	
	//멤버변수
	private int pno;
	private String pname;
	private int price;
	private String regdate;
	private String madeby;
	
	
	//생성자
	public productVO() {}
	
	//상품 등록 pname, price, madeby
	public productVO(String pname, int price, String madeby) {
		this.pname = pname;
		this.price = price;
		this.madeby = madeby;
	}
	
	//상품 리스트 pno, pname, regdate
	public productVO(int pno, String pname, String madeby) {
		this.pno = pno;
		this.pname = pname;
		this.madeby = madeby;
	}
	
	
	//상품 수정 pno, pname, price, madeby
	public productVO(int pno, String pname, int price, String madeby) {
		this.pno = pno;
		this.pname = pname;
		this.price = price;
		this.madeby = madeby;
	}

	

	//상품 상세페이지 pno, pname, price, regdate, madeby
	public productVO(int pno, String pname, int price, String regdate, String madeby) {
		this.pno = pno;
		this.pname = pname;
		this.price = price;
		this.regdate = regdate;
		this.madeby = madeby;
	}

	//getter,setter
	public int getPno() {
		return pno;
	}

	public void setPno(int pno) {
		this.pno = pno;
	}

	public String getPname() {
		return pname;
	}

	public void setPname(String pname) {
		this.pname = pname;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getRegdate() {
		return regdate;
	}

	public void setRegdate(String regdate) {
		this.regdate = regdate;
	}

	public String getMadeby() {
		return madeby;
	}

	public void setMadeby(String madeby) {
		this.madeby = madeby;
	}
	
	//toString
	@Override
	public String toString() {
		return "productVO [pno=" + pno + ", pname=" + pname + ", price=" + price + ", regdate=" + regdate + ", madeby="
				+ madeby + "]";
	}
	
	
	
}

 


6. contoroller 에 servlet 만들기

이렇게 먼저 주석처리를 해주고!

 

 

이것만 남기고 다 날리기! 끝!

 

이제 다시 주석제거!

 


7. 화면 구성 짜기