Spring-boot25 Spring-boot 글 수정하기 boardcontroller - 우선 글 목록에서 수정 버튼을 눌렀을 때 id에 맞는 정보를 보여주게 컨트롤러에서 작업해준다. @GetMapping("/update/{id}") public String updateForm(@PathVariable(name = "id") Long id, Model model) { BoardDTO boardDTO = boardService.findById(id); model.addAttribute("boardUpdate",boardDTO); return "update"; } update.html writer: pass: title: contents: 여기까지 작성해서 수정버튼을 눌러보고 비밀번호 막 입력했을 때 alert을 나오게 된다면 세입~ 다시 boardcontroll.. 2024. 2. 24. Spring-boot 글 조회하기 id title writer date hits contents image 목록 수정 삭제 전에 list.html에서 id번호를 클릭하면 이동할 수 있게 a 링크가 되어있을 것이다. boardcontroller : 여기선 디테일 페이를 보여주면서 조회수를 올리는 작업을 같이 한다 . @GetMapping("/{id}") public String findById(@PathVariable Long id, Model model) { boardService.updateHits(id); BoardDTO boardDTO = boardService.findById(id); model.addAttribute("board", boardDTO); return "detail"; } boardrepository 여기서는 두 가.. 2024. 2. 23. Spring-boot 글목록 가져오기 index.html에 글 목록 링크를 넣어준다. 글 작성 글 작성 링크 글 목록 boardController를 작업해준다. @GetMapping("/") public String findAll(Model model) { List boardDTOList = boardService.findAll(); model.addAttribute("boardList", boardDTOList); return "list"; } boardservice에 findAll을 선언해준다. @Transactional public List findAll() { List boardEntityList = boardRepository.findAll(); List boardDTOList = new ArrayList(); for(BoardEn.. 2024. 2. 23. Spring-boot 게시글 작성 Controller의 페이지 이동을 해본다 우선 다음과 같이 폴더 구조를 만들어 준다 HomeController package org.home.index.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class HomeController { @GetMapping("/") public String index() { return "index"; } } BoardController package org.home.index.controller; import org.springframework.stereotype.. 2024. 2. 23. 이전 1 ··· 3 4 5 6 7 다음