Spring49 [SpringBoot] 간단한 게시판 생성_페이징처리 1. 게시판 페이징 처리 1) controller @GetMapping("/board/list") public String boardList(Model model, @PageableDefault(page = 0, size = 10, sort = "id", direction = Sort.Direction.DESC) Pageable pageable, String searchKeyword){ Page list = null; if(searchKeyword != null){ list = boardService.boardSearchList(searchKeyword, pageable); } else { list = boardService.boardList(pageable); } int nowPage = list.ge.. 2024. 1. 20. [SpringBoot] 간단한 게시판 생성_첨부파일 업로드 1. 게시판 파일 업로드 1) 데이터베이스 내 column 추가 - filename, filepath 2) entity private String filename; private String filepath; public String getFilename() { return filename; } public void setFilename(String filename) { this.filename = filename; } public String getFilepath() { return filepath; } public void setFilepath(String filepath) { this.filepath = filepath; } 추가한 column에 대한 entity 변수 정의 3) view (html.. 2024. 1. 15. [SpringBoot] 간단한 게시판 생성_글수정 1. 게시물 수정 1) view(html) boardview.html 제목입니다. 내용이 들어갈 부분입니다. 글 삭제 글 수정 a태그에 id를 지정 path variable방식은 주소창에 /{번호} 식으로 나타냄 2) controller @GetMapping("/board/modify/{id}") public String boardModify(@PathVariable("id") Integer id, Model model){ model.addAttribute("board",boardService.boardView(id)); return "boardmodify"; } 경로 매핑에서 path variable 방식 사용 메서드에 들어가는 인자 @PathVariable("id")를 해주어야 함 GetMapping.. 2024. 1. 15. [SpringBoot] 간단한 게시판 생성_목록, 상세, 삭제 1. 게시물 목록 페이지 이동 1) controller @GetMapping("/board/list") public String boardList(Model model){ model.addAttribute("list",boardService.boardList()); return "boardlist"; } 2) service public List boardList(){ return boardRepository.findAll(); } .findAll() : Board라는 class가 담긴 list를 찾아 반환 3) view(html) 글 번호 제목 1 제목입니다. html 태그에 xmlns:th="https://www.thymeleaf.org" 선언 : thymeleaf 탬플릿을 통해 데이터 받아옴 th:e.. 2024. 1. 14. 이전 1 ··· 9 10 11 12 13 다음