no image
[STS3] 파일 업로드(2)
DB에 테이블 생성 create table tbl_attach( uuid varchar2(100) not null, uploadPath varchar2(200) not null, fileName varchar2(100) not null, filetype char(1) default 'I', bno number); alter table tbl_attachadd constraint tbl_attach_uuid_PK primary key(uuid);alter table tbl_attachadd constraint tbl_attach_bno_FK foreign key(bno) refer..
2024.04.24
no image
[STS3] 댓글 기능(4)
BoardDTO에 댓글 수 항목 추가private int replycnt; DB에도 컬럼 추가 후 기존 게시물들에 댓글 수 업데이트alter table tbl_boardadd (replycnt number default 0);update tbl_boardset replycnt = (select count(rno) from tbl_reply where tbl_reply.bno = tbl_board.bno);commit; boardMapper.xml에 있는 getListWithPaging select문에 replycnt를 추가하고 하단에 조회수, 댓글수 update문 추가 (#{pageNum}..
2024.04.24
no image
[STS3] 트랜잭션
root-context.xml 에 bean 추가  DB에 샘플 테이블 두개 생성create table tbl_sample1( col1 varchar2(500));create table tbl_sample2( col2 varchar2(50)); src/main/java 경로에 있는 mapper 패키지에 Sample1Mapper 인터페이스 추가 후 작성public interface Sample1Mapper { public int insertCol1(String data); public int insertCol2(String data); } src/main/resources 경로에 있는 mappers 패키지에 Sample1Mapper.xml 생성..
2024.04.24
no image
[STS3] 댓글 기능(3)
resources 폴더 안에 있는 js폴더에 reply.js 파일 생성 후 작성 /** * */ console.log("Reply"); var replyService = (function(){ function add(reply, callback){ console.log("reply......"); $.ajax({ type : "post", url : reply.contextPath + "/replies/new", data : JSON.stringify(reply), contentType : "application/json; charset=utf-8", success : function(result, status, xhr) { if (callback) { callback(result); } }, error..
2024.04.23
no image
[STS3] 댓글 기능(2)
src/main/java 경로에 있는 service 패키지에 IRelpyService 인터페이스 작성 public interface IReplyService { public int register(ReplyDTO rDto); public ReplyDTO read(int rno); public int modify(ReplyDTO rDto); public int remove(int rno); public List getList(Criteria cri, int bno); } imbl 패키지에 ReplyServiceImpl 클래스 작성 @Service @Log4j public class ReplyServiceImpl implements IReplyService{ @Autowired private ReplyMap..
2024.04.22
no image
[STS3] 댓글 기능(1)
db에 테이블 생성 create table tbl_reply( rno number(10) not null, bno number(10) not null, replytext varchar2(1000) not null, replyer varchar2(50) not null, regdate date default sysdate, updatedate date default sysdate ); create unique index IDX_tbl_reply_PK on tbl_reply (bno desc, rno asc); alter table tbl_reply add constraint tbl_reply_rno_PK primary key(rno); alter table tbl_reply add constraint tb..
2024.04.22
no image
[STS3] 파일 업로드(1)
https://mvnrepository.com/artifact/net.coobird/thumbnailator/0.4.8 페이지 하단 코드 복사 후 pom.xml에 붙여넣기 fileUpload 폴더 생성 src/main/java 경로에 UploadController 클래스 추가 후 작성 @Controller @Log4j public class UploadController { private String uploadPath = "D:\\PDH\\workspace\\sts\\springstudent\\src\\main\\webapp\\resources\\fileUpload"; public void uploadForm() { log.info("upload form.........................."..
2024.04.22
no image
[STS3] Mapper를 활용하여 게시판 구현(7)
검색기능을 구현하기 위해 Criteria 파일 수정 @Data public class Criteria { private int pageNum; private int amount; private String type; private String keyword; public Criteria() { this(1, 10); } public Criteria(int pageNum, int amount) { this.pageNum = pageNum; this.amount = amount; } public String[] getTypeArr() { return type == null? new String[] {} : type.split(""); } } boardMapper.xml 파일에 getListWithPaging..
2024.04.18
no image
[STS3] Mapper를 활용하여 게시판 구현(6)
src/main/java 경로에 있는 domain 패키지에 PageDTO 생성 후 작성 @Data public class PageDTO { private int startPage; private int endPage; private boolean prev, next; private int total; private Criteria cri; public PageDTO(Criteria cri, int total) { this.cri = cri; this.total = total; this.endPage = (int) (Math.ceil(cri.getPageNum() / 10.0)) * 10; this.startPage = this.endPage - 9; int realEnd = (int) (Math.ceil..
2024.04.18