AuthorService.java
인터페이스에 아래의 메서드를 선언한다. /* 작가 목록 */
public List<AuthorVO> authorGetList(Criteria cri) throws Exception;
AuthorGetList()
메서드를 호출하고 List를 반환받아야 하기 때문에 return에 Mapper의 메서드를 호출한다.@log4j
어노테이션을 선언하면 된다.package com.store.service;
import java.util.List;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.store.mapper.AuthorMapper;
import com.store.model.AuthorVO;
import com.store.model.Criteria;
@Service
public class AuthorServiceImpl implements AuthorService{
private static final Logger log = LoggerFactory.getLogger(AuthorServiceImpl.class);
@Autowired
AuthorMapper authorMapper;
/* 작가 등록 */
@Override
public void authorEnroll(AuthorVO author) throws Exception {
authorMapper.authorEnroll(author);
}
/* 작가 목록 */
@Override
public List<AuthorVO> authorGetList(Criteria cri) throws Exception {
log.info("(service)authorGetList()......." + cri);
return authorMapper.authorGetList(cri);
}
}
authorManage
url 매핑 메서드인 authorManageGET()
에 파라미터로 Criteria, Model 클래스를 부여한다.authorManage.jsp
에 넘겨주기 위해 파라미터로 부여했다. /* 작가 관리 페이지 접속 */
@RequestMapping(value = "authorManage", method = RequestMethod.GET)
public void anthorManageGET(Criteria cri, Model model) throws Exception {
logger.info(">>>>>>>>>> 작가 관리 페이지 접속");
}
AuthorService
의 authorGetList()
메서드를 호출하여 반환받은 결과를 list
속성명에 저장하여 전달해주는 코드를 작성한다. /* 작가 관리 페이지 접속 */
@RequestMapping(value = "authorManage", method = RequestMethod.GET)
public void anthorManageGET(Criteria cri, Model model) throws Exception {
logger.info(">>>>>>>>>> 작가 관리 페이지 접속");
/* 작가 목록 출력 데이터 */
List list = authorService.authorGetList(cri);
model.addAttribute("list", list);
}
AuthorVO
에 정의되어 있는 소속 국가 이름(nationName)은 반환되지 않는다. 반환받도록 쿼리문을 작성할 수 있지만 다른 표에서 데이터를 가져와야 하기 때문에 자원을 좀 더 많이 소모하게 된다.setNationId()
메서드의 구현부에 아래의 코드를 추가한다. public void setNationId(String nationId) {
this.nationId = nationId;
if (nationId.equals("01")) {
this.nationName = "국내";
} else {
this.nationName = "국외";
}
}
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
admin_content_subject
인 div태그 다음 순서에 아래의 코드를 추가해준다.<div class="author_table_wrap">
<table class="author_table">
<thead>
<tr>
<td class="th_column_1">작가 번호</td>
<td class="th_column_2">작가 이름</td>
<td class="th_column_3">작가 국가</td>
<td class="th_column_4">등록 날짜</td>
<td class="th_column_5">수정 날짜</td>
</tr>
</thead>
<c:forEach items="${list}" var="list">
<tr>
<td><c:out value="${list.authorId}"></c:out> </td>
<td><c:out value="${list.authorName}"></c:out></td>
<td><c:out value="${list.nationName}"></c:out> </td>
<td><fmt:formatDate value="${list.regDate}" pattern="yyyy-MM-dd"/></td>
<td><fmt:formatDate value="${list.updateDate}" pattern="yyyy-MM-dd"/></td>
</tr>
</c:forEach>
</table>
</div>
</div>
<c:foreach>
태그를 활용하여 출력시켰다.<fmt:formDate>
태그를 활용하였다. /* 작가 목록 영역 */
.author_table_wrap{
padding: 20px 35px
}
.author_table{
width: 100%;
border: 1px solid #d3d8e1;
text-align: center;
border-collapse: collapse;
}
.author_table td{
padding: 10px 5px;
border : 1px solid #e9ebf0;
}
.author_table thead{
background-color: #f8f9fd;
font-weight: 600;
}
.th_column_1{
width:120px;
}
.th_column_3{
width:110px;
}
.th_column_4{
width:140px;
}
.th_column_5{
width:140px;
}