src - main - webapp에 sql폴더 생성하기
sql폴더안에 myboard.sql 파일 추가하기
table 및 seq 추가
pom.xml 환경설정
<script>
location.href="home.do";
</script>
추가 하여 테스트(오류 없음)
package myspring.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import myspring.service.BoardService;
@Controller
public class BoardController {
@Autowired
private BoardService service;
}
package myspring.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import myspring.dao.BoardDao;
@Service
public class BoardService {
@Autowired
private BoardDao dao;
}
package myspring.dao;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class BoardDao {
// @Autowired
// private SqlSessionon session;
}
index.jsp 실행하여 테스트
Board 설정(DTO)
package myspring.model;
import java.util.Date;
public class Board {
private int no;
private String writer;
private String passwd;
private String subject;
private String content;
private int readcount;
private Date register;
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getReadcount() {
return readcount;
}
public void setReadcount(int readcount) {
this.readcount = readcount;
}
public Date getRegister() {
return register;
}
public void setRegister(Date register) {
this.register = register;
}
}
<typeAlias alias="board" type="mypsring.model.board" />
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="boardns">
</mapper>