![article thumbnail image](https://blog.kakaocdn.net/dn/cO9PBJ/btrTefXCA3l/7MKhykLRt26L1tPBR9uCk0/img.png)
728x90
링크 걸기 - a 태그
{{>layouts/header}}
<table class="table">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Title</th>
<th scope="col">Content</th>
</tr>
</thead>
<tbody>
{{#article}}
<tr>
<th>{{id}}</th>
<td>{{title}}</td>
<td>{{content}}</td>
</tr>
{{/article}}
</tbody>
</table>
<a href="/articles/{{article.id}}/edit" class="btn btn-primary">Edit</a>
<a href="/articles">Go to Article List</a>
{{>layouts/footer}}
수정 페이지 작성
{{>layouts/header}}
{{#article}}
<form class="container" action="" method="post">
<div class="mb-3">
<label class="form-label">제목</label>
<input type="text" class="form-control" name="title" value="{{title}}">
</div>
<div class="mb-3">
<label class="form-label">내용</label>
<textarea class="form-control" rows="3" name="content">{{content}}</textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<a href="/articles/{{article.id}}">back</a>
</form>
{{/article}}
{{>layouts/footer}}
요청 받기 - 컨트롤러, GetMapping.
@GetMapping("/articles/{id}/edit")
public String edit(@PathVariable Long id, Model model){
//수정할 데이터를 가져오기!
Article articleEntity = articleRepository.findById(id).orElse(null);
//모델에 데이터를 등록
model.addAttribute("article", articleEntity);
//뷰 페이지 설정
return "articles/edit";
}
728x90
'Study > SpringBoot WebProject' 카테고리의 다른 글
Spring Boot 링크와 리다이렉트 (0) | 2022.12.09 |
---|---|
Spring Boot 데이터 목록 조회하기 (0) | 2022.12.09 |
Spring boot 데이터 조회하기 with JPA (0) | 2022.12.09 |
Spring Boot lombok과 refactoring (1) | 2022.11.03 |
Spring Boot DB테이블과 SQL (0) | 2022.11.03 |