Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 자바편
- network configuration
- 처음 만나는 AI수학 with Python
- resttemplate
- 데비안
- ㅒ
- 페이징
- Kernighan의 C언어 프로그래밍
- 자료구조와함께배우는알고리즘입문
- 구멍가게코딩단
- 서버설정
- 이터레이터
- 코드로배우는스프링부트웹프로젝트
- 자료구조와 함께 배우는 알고리즘 입문
- 선형대수
- /etc/network/interfaces
- 네트워크 설정
- 친절한SQL튜닝
- baeldung
- 스프링 시큐리티
- 스프링부트핵심가이드
- 티스토리 쿠키 삭제
- d
- 처음 만나는 AI 수학 with Python
- 목록처리
- iterator
- GIT
- 알파회계
- 코드로배우는스프링웹프로젝트
- 리눅스
Archives
- Today
- Total
bright jazz music
[bootBoard] N:1(다대일) 연관관계: 10-3 화면처리: 게시물 조회 처리 본문
Framework/Spring
[bootBoard] N:1(다대일) 연관관계: 10-3 화면처리: 게시물 조회 처리
bright jazz music 2022. 10. 9. 22:071. BoardController에 조회를 위한 코드 추가
//BoardController.java
package com.example.bootboard.controller;
@Controller
@RequestMapping("/board/")
@Log4j2
@RequiredArgsConstructor
public class BoardController {
private final BoardService boardService;
...
//조회
@GetMapping("/read")
public void read(@ModelAttribute("requestDTO") PageRequestDTO pageRequestDTO,
Long bno, Model model) {
log.info("bno: " + bno);
BoardDTO boardDTO = boardService.get(bno);
log.info(boardDTO);
model.addAttribute("dto", boardDTO);
}
...
}
2. 게시글 조회를 위한 페이지 생성read.html
read.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<th:block th:replace="~{/layout/basic :: setContent(~{this::content} )}">
<th:block th:fragment="content">
<h1 class="mt-4">Board Read Page</h1>
<div class="form-group">
<label >Bno</label>
<input type="text" class="form-control" name="gno" th:value="${dto.bno}" readonly >
</div>
<div class="form-group">
<label >Title</label>
<input type="text" class="form-control" name="title" th:value="${dto.title}" readonly >
</div>
<div class="form-group">
<label >Content</label>
<textarea class="form-control" rows="5" name="content" readonly>[[${dto.content}]]</textarea>
</div>
<div class="form-group">
<label >Writer</label>
<input type="text" class="form-control" name="writer" th:value="${dto.writerName}" readonly>
</div>
<div class="form-group">
<label >RegDate</label>
<input type="text" class="form-control" name="regDate" th:value="${#temporals.format(dto.regDate, 'yyyy/MM/dd HH:mm:ss')}" readonly>
</div>
<div class="form-group">
<label >ModDate</label>
<input type="text" class="form-control" name="modDate" th:value="${#temporals.format(dto.modDate, 'yyyy/MM/dd HH:mm:ss')}" readonly>
</div>
<a th:href="@{/board/modify(bno = ${dto.bno}, page=${requestDTO.page}, type=${requestDTO.type}, keyword =${requestDTO.keyword})}">
<button type="button" class="btn btn-primary">Modify</button>
</a>
<a th:href="@{/board/list(page=${requestDTO.page} , type=${requestDTO.type}, keyword =${requestDTO.keyword})}">
<button type="button" class="btn btn-info">List</button>
</a>
</th:block>
</th:block>
3. 결과
게시글 클릭 시 조회 페이지로 이동한다.
댓글과 관련된 작업은 모두 게시물의 조회 페이지에서 댓글의 숫자를 보여주거나 댓글을 입력하는 화면 등을 추가하게 된다.
'Framework > Spring' 카테고리의 다른 글
[bootBoard] N:1(다대일) 연관관계: 11-1. 검색처리: JQPL을 사용한 검색 (0) | 2022.10.09 |
---|---|
[bootBoard] N:1(다대일) 연관관계: 10-4 화면처리: 게시물 수정/삭제 처리 (0) | 2022.10.09 |
[bootBoard] N:1(다대일) 연관관계: 10-2 화면처리: 게시물 등록 처리 (0) | 2022.10.09 |
[bootBoard] N:1(다대일) 연관관계: 10-1 화면처리: 목록, 페이징 (0) | 2022.10.08 |
[bootBoard] N:1(다대일) 연관관계: 9-5. 프로젝트 적용: 게시물 수정 처리 (0) | 2022.10.08 |
Comments