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 | 29 | 30 |
Tags
- NCS
- html
- 데이터베이스
- VLAN
- w3school
- Oracle
- 라우터
- 네트워크관리사
- 자바
- Java
- javaee
- 이것이 자바다
- sql
- 버추얼머신
- jsp연결
- 정보처리기사
- jsp
- 정처기필기
- rinux
- 원형그래프
- 네트워크
- Cisco
- 오라클
- ospf
- php
- autoset
- cisco packet
- 리눅스
- ciscopacket
- 참조타입
Archives
- Today
- Total
기록해! 정리해!
JPAJarTymeleaf-1 상세보기, 삭제하기, 수정하기 본문
getBoardList 타이틀에 링크걸어서 상세보기 만들기
1. BoardService
2. BoardServiceImpl
package com.rubypaper.board;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class BoardServiceImpl implements BoardService{
@Autowired
private BoardRepository boardRepo;
@Override
public void insert(Board vo) {
boardRepo.save(vo);
}
@Override
public List<Board> getBoardList() {
return (List<Board>)boardRepo.findAll();
}
@Override
public Optional<Board> getBoard(Long seq) {
return boardRepo.findById(seq);
}
}
3. BoardController
@RequestMapping("/getBoard.do")
public void getBoard(Model model, Board vo) {
model.addAttribute("m", boardService.getBoard(vo.getSeq()).get());
}
4. getBoard
<html xmlns:th="http://www.thymeleaaf.org">
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<br>
<h2> 상세보기 <a href=index.html>(처음으로)</a> </h2>
<table border=1>
<tr><td>SEQ</td> <td th:text="${m.seq}" /></tr>
<tr><td>TITLE</td> <td th:text="${m.title}"/></tr>
<tr><td>WRITER</td> <td th:text="${m.writer}" /></tr>
<tr><td>CONTENT</td> <td th:text="${m.content}" /></tr>
<tr><td>PASSWORD</td> <td th:text="${m.password}" /></tr>
<tr><td>DATE</td> <td th:text="${m.createDate}" /></tr>
<tr><td>cnt</td> <td th:text="${m.cnt}" /></tr>
</table>
</div>
</body>
</html>
5. getBoardList 타이틀에 링크걸기
<td><a th:href=@{getBoard.do(seq=${m.seq})}> [[${m.title}]] </a></td>
>>
getBoardList 작성자에 링크걸어서 삭제하기
1. BoardService
2. BoardServiceImpl
3. BoardController
4. getBoardList에 링크걸기
>>
상세보기에 수정하기 만들기
1. BoardService
2. BoardServiceImpl
3. BoardController
4. getBoard
<html xmlns:th="http://www.thymeleaaf.org">
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<br>
<h2> 상세보기 <a href=index.html>(처음으로)</a> </h2>
<form action=update.do>
<table border=1>
<tr><td>SEQ</td> <td> <input type=text name=seq th:value="${m.seq}" /></td></tr>
<tr><td>TITLE</td> <td> <input type=text name=title th:value="${m.title}" /></td></tr>
<tr><td>WRITER</td> <td> <input type=text name=writer th:value="${m.writer}" /></td></tr>
<tr><td>CONTENT</td> <td> <input type=text name=content th:value="${m.content}" /></td></tr>
<tr><td>PASSWORD</td> <td> <input type=text name=password th:value="${m.password}" /></td></tr>
<tr><td>DATE</td> <td th:text="${m.createDate}" /></tr>
<tr><td>cnt</td> <td th:text="${m.cnt}" /></tr>
<tr><td colspan=2 align=center><input type=submit th:value="수정하기"></td></tr>
</table>
</form>
</div>
</body>
</html>
>>
'SpringBoot' 카테고리의 다른 글
JPAJarThymeleaf-2 (Board, QLogin) (0) | 2022.10.19 |
---|---|
JPAJarTymeleaf-1 검색하기 ( 동적 DSL 사용하기 ) (0) | 2022.10.18 |
JPAJarTymeleaf-1 UI (getBoardList, form) (0) | 2022.10.18 |
JPAJarTymeleaf-1 Test(Crudrepository 메소드사용) (0) | 2022.10.18 |
JPAJarTymeleaf-1 (board) (0) | 2022.10.18 |
Comments