이제 본격적으로
Spring Framework를 이용해서 쇼핑몰 회원관리 홈페이지를 구현해보자
[ SELECT * FROM member_tbl_02;]
[SELECT * FROM money_tbl_02; ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import url="header.jsp" />
<section>
<br><br>
<div align="center"><font size=5> 쇼핑몰 회원관리 프로그램</font></div> <br>
<div> 쇼핑몰 회원정보와 회원매출 정보 데이터베이스를 구출하고
회원관리 프로그램을 작성하는 프로그램이다. <br>
</div>
<div>
<br> 프로그램 작성 순서
<ol>
<li> 회원 정보 테이블을 생성한다.
<li> 매출 정보 테이블을 생성한다.
<li> 회원 정보, 매출정보 테이블에 제시된 문제지와 참조데이터를 추가 생성한다.
<li> 회원 정보 입력 화면 프로그램을 작성한다.
<li> 회원 정보 조회 프로그램을 작성한다.
<li> 회원 매출 정보 조회 프로그램을 작성한다.
</ol>
</div>
</section>
<c:import url="footer.jsp" />
A:link {color: #FFFFFF; text-decoration: none;}
A:visited {color: #FFFFFF; text-decoration: none;}
A:active {color: #FFFFFF; text-decoration: none;}
A:hover {color: #000000; text-decoration: underline;}
해당 효과를 넣어서 nav 부분 목록의 글씨를 꾸며주었다.
package com.springbook.biz.jungbo.common;
public class MemberVO {
private int custno;
private String custname;
private String phone;
private String address;
private String joindate;
private String grade;
private String city;
public int getCustno() {
return custno;
}
public void setCustno(int custno) {
this.custno = custno;
}
public String getCustname() {
return custname;
}
public void setCustname(String custname) {
this.custname = custname;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getJoindate() {
return joindate;
}
public void setJoindate(String joindate) {
this.joindate = joindate.substring(0, 10);
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
@Override
public String toString() {
return "MemberVO [custno=" + custno + ", custname=" + custname + ", phone=" + phone + ", address=" + address
+ ", joindate=" + joindate + ", grade=" + grade + ", city=" + city + "]";
}
}
MoneyVO
package com.springbook.biz.jungbo.common;
public class MoneyVO {
private int custno;
private int salenol;
private int pcost;
private int amount;
private int price;
private String pcode;
private String sdate;
public int getCustno() {
return custno;
}
public void setCustno(int custno) {
this.custno = custno;
}
public int getSalenol() {
return salenol;
}
public void setSalenol(int salenol) {
this.salenol = salenol;
}
public int getPcost() {
return pcost;
}
public void setPcost(int pcost) {
this.pcost = pcost;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getPcode() {
return pcode;
}
public void setPcode(String pcode) {
this.pcode = pcode;
}
public String getSdate() {
return sdate;
}
public void setSdate(String sdate) {
this.sdate = sdate.substring(0, 10);
}
@Override
public String toString() {
return "MoneyVO [custno=" + custno + ", salenol=" + salenol + ", pcost=" + pcost + ", amount=" + amount
+ ", price=" + price + ", pcode=" + pcode + ", sdate=" + sdate + "]";
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import url="header.jsp" />
<section>
<br><br>
<div align="center"><font size=5> 회원정보 입력하기 </font></div> <br>
<div align="center">
<br><br>
<form action="insert.do">
<table border=1 width=600>
<tr>
<td align=center>회원성명 </td>
<td> <input type=text name=custname size=10></td>
</tr>
<tr>
<td align=center>회원전화 </td>
<td><input type=text name=phone size=20></td>
</tr>
<tr>
<td align=center>회원주소 </td>
<td><input type=text name=address size=40></td>
</tr>
<tr>
<td align=center>가입일자 </td>
<td><input type=text name=joindate size=10></td>
</tr>
<tr>
<td align=center>고객등급<br>[A:VIP,B:일반,C:직원] </td>
<td><input type=text name=grade size=10></td>
</tr>
<tr>
<td align=center>도시코드 </td>
<td><input type=text name=city size=10> </td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=submit value="등록">  
<input type=button value="조회">
</td>
</tr>
</table>
</form>
</div>
</section>
<c:import url="footer.jsp" />
@RequestMapping(value="/insert.do", method=RequestMethod.GET)
public String insert(MemberVO vo) throws Exception {
s.insertMember(vo);
return "result.jsp";
}
@Autowired
JungboDAO dao;
@Override
public void insertMember(MemberVO vo) {
dao.insertMember(vo);
}
@Autowired
JdbcTemplate jdbcTemplate;
String insert_sql="insert into member_tbl_02 (custno, custname, phone, address, joindate, grade, city) values ((select max(custno) from member_tbl_02)+1, ?, ?, ?, ?, ?, ?) ";
@Override
public void insertMember(MemberVO vo) {
Object[] args = {vo.getCustname(), vo.getPhone(),vo.getAddress(), vo.getJoindate(), vo.getGrade(), vo.getCity()};
jdbcTemplate.update(insert_sql, args);
}