Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
Tags
- react
- 자바스크립트
- 자바스크립트기초문법
- 구글 oauth
- springboot
- 자바스크립트기초
- 구글캘린더api
- 기초 코딩
- HTML
- js
- mybatis
- 코딩
- 스프링부트
- 웹앱
- 자바스크립트 기초
- Spring Boot
- 리액트프로젝트세팅
- 리액트초기세팅
- javaspring
- 리액트세팅
- java
- 자바
- 웹
- 기초코딩
- spring
- 처음만나는자바스크립트
- 전자정부 서버세팅
- Javascript
- CSS
- 마이바티스
Archives
- Today
- Total
인생 디벨로퍼
[Bank App] 9강 계좌목록보기 본문
728x90
쿼리 만들기
유저 id 로, 계좌 목록을 조회할 수 있는 쿼리를 만듦
select * from account_tb where user_id = 1;
Account xml 파일 mapper
<select id="findUserById" resultType="shop.mtcoding.bankapp.model.account.Account">
select * from account_tb where user_id = #{principalId}
</select>
Repository
public List<Account> findUserById(Integer principalId);
Controller
기존 코드에, list 보기 추가
@GetMapping({ "/", "/account" })
public String main(Model model) {
User principal = (User) session.getAttribute("principal");
if (principal == null) {
return "redirect:/loginForm";
}
List<Account> accountList = accountRepository.findUserById(principal.getId());
model.addAttribute("accountList", accountList);
return "account/main";
}
main.jsp 수정
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../layout/header.jsp" %>
<div class="m-4">
<p class="text-center fs-4" style="font-weight: bolder;">메인페이지</p>
<div class="my_form">
<hr />
<table class="table">
<thead class="text-center">
<tr>
<th scope="col" style="font-weight: bolder;">계좌번호</th>
<th scope="col" style="font-weight: bolder;">잔액</th>
</tr>
<tbody class="table-group-divider text-center">
<c:forEach items="${accountList}" var="accountList">
<tr>
<td scope="row">${accountList.number}</td>
<td>${accountList.balance}원</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
결과
728x90
'Project > 개인 Project - Bank App' 카테고리의 다른 글
[Bank App] 11강 입금하기 (0) | 2023.06.16 |
---|---|
[Bank App] 10강 출금하기 (0) | 2023.06.16 |
[Bank App] 8강 계좌생성하기 (0) | 2023.06.14 |
[Bank App] 7강 로그인 만들기 (0) | 2023.06.14 |
[Bank App] 6강 회원가입 만들기 (0) | 2023.06.10 |