BoardDAO
public List<BoardVO> new_list(BoardVO b) throws Exception;// main 최신글 목록
BoardDAOImpl
@Override
public List<BoardVO> new_list(BoardVO b) throws Exception {
return sqlSession.selectList(namespace+".new_list", b);
}
BoardService
public List<BoardVO> new_list(BoardVO b) throws Exception;// main 최신글 목록
BoardServiceImpl
@Override
public List<BoardVO> new_list(BoardVO b) throws Exception {
return dao.new_list(b);
}
BoardMapper
<select id="new_list" resultType="BoardVO">
<![CDATA[
select * from board where id=#{id} and not tab='v' order by regdate desc limit 0,4;
]]>
</select>
BoardController
@GetMapping("/main")
public void mainGET(Model model, BoardVO b) throws Exception {
//logger.info("main start====");
model.addAttribute("new_list", service.new_list(b));
}
main.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/views/include/header_board.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>미니홈피</title>
<style>
.b_list { /* 최신글 list */
/* border:1px solid blue; */
width:325px;
margin-right:5px;
font-size:13px;
}
p {
padding:0px 10px;
}
</style>
<div class="b_list">
<div style="color:#54B3D3;font-weight: bolder;">Updated news</div>
<hr>
<!-- 최신글 4개 계속 업데이트! -->
<div>
<c:forEach var="boardVO" items="${new_list}">
<c:set var="title" value="${boardVO.title }"/>
<c:choose>
<c:when test="${boardVO.tab == 'b'}">
<a href="/board/view?id=${boardVO.id}&tab=${boardVO.tab}&fno=${boardVO.fno}&bno=${boardVO.bno}" style="color:black;">
<p>
[ 게시판 ]
<c:choose>
<c:when test="${fn:length(title) gt 30}">
${fn:substring(title,0,30)}...
</c:when>
<c:otherwise>
${boardVO.title }
</c:otherwise>
</c:choose>
</p>
</a>
</c:when>
<c:otherwise>
<a href="/board/list?id=${boardVO.id}&tab=${boardVO.tab}&fno=${boardVO.fno}&bno=${boardVO.bno}" style="color:black;">
<p>
[ 사진첩 ]
<c:choose>
<c:when test="${fn:length(title) gt 30}">
${fn:substring(title,0,30)}...
</c:when>
<c:otherwise>
${boardVO.title }
</c:otherwise>
</c:choose>
</p>
</a>
</c:otherwise>
</c:choose>
</p></a>
</c:forEach>
</div>
<!-- 최신글 4개 계속 업데이트! 끝 -->
</div>
<%@include file="/WEB-INF/views/include/footer_board.jsp" %>
'프로젝트 로직 모음집 > spring' 카테고리의 다른 글
Today is 기분선택 (0) | 2023.06.03 |
---|---|
게시판별 new수/총수 (0) | 2023.06.03 |
선택삭제 (0) | 2023.06.02 |