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 | 31 |
Tags
- form
- error
- java
- 드라이브 연결
- pagination
- 비교표현식
- anaconda
- ibatis
- sqldeveloper
- mybatis
- pl/sql
- pymssql
- sqlMapClient
- directivesTag
- Oracle
- sql
- javascript
- DB 스케쥴러
- spring
- sqlMapConfig
- Git
- 파이썬
- PYTHON
- eclipse
- form태그
- JSP
- select문
- fastapi
- androidstudio
- pyqt
Archives
- Today
- Total
기록하는 코더
[Spring] mybatis - HashMap 형태로 데이터 받아오기 본문
데이터를 받아올 때 주로 VO를 사용하지만
HashMap을 이용해서 값을 받아오는 연습을 해보자.
book.SQL.mxl
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="Book">
<select id="selectBookList" parameterType="hashMap" resultType="hashMap">
SELECT BOOK_ID, TITLE, CATEGORY, PRICE, INSERT_DATE, CONTENT
FROM BOOK
WHERE 1=1
</select>
</mapper>
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/resources/js/jquery-3.6.0.js"></script>
<title>도서관리시스템</title>
</head>
<body>
<table border="1">
<tr>
<th>번호</th>
<th>책제목</th>
<th>카테고리</th>
<th>가격</th>
</tr>
<c:choose>
<c:when test="${empty list }">
<tr>
<td colspan="4">조회하신 게시글이 존재하지 않습니다.</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach items="${list}" var="book" varStatus="stat">
<tr>
<td>${book.book_id}</td>
<td>${book.title}</td>
<td>${book.category}</td>
<td>${book.price}</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</table>
</body>
</html>
book list를 가져올 때 소문자로 쓰면 값이 출력되지 않는다.
원인
mapper.xml에서 쿼리문을 대문자로 썼을 때 hashMap 내에 키 값이 대문자로 들어가기 때문에
키값이 맞지 않아 값을 찾아오지 못함
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/resources/js/jquery-3.6.0.js"></script>
<title>도서관리시스템</title>
</head>
<body>
<table border="1">
<tr>
<th>번호</th>
<th>책제목</th>
<th>카테고리</th>
<th>가격</th>
</tr>
<c:choose>
<c:when test="${empty list }">
<tr>
<td colspan="4">조회하신 게시글이 존재하지 않습니다.</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach items="${list}" var="book" varStatus="stat">
<tr>
<td>${book.BOOK_ID}</td>
<td>${book.TITLE}</td>
<td>${book.CATEGORY}</td>
<td>${book.PRICE}</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</table>
</body>
</html>
대문자로 키 값을 지정해주면 값이 잘 받아와진다.
'DataBase > Oracle' 카테고리의 다른 글
[Oracle] DB스케쥴러 (0) | 2023.04.06 |
---|---|
[Oracle] 조인 Join (0) | 2023.01.31 |
[Oracle] PL/SQL Procedure (0) | 2023.01.25 |
[Oracle] 데이터타입 - 문자열 자료형 (0) | 2023.01.15 |
[Oracle] 데이터베이스 접속 계정 만드는 방법 (0) | 2023.01.07 |