본문 바로가기

Spring/Spring

1216 Spring -

728x90
반응형
boardController
@RequestMapping(value ="/list", method = RequestMethod.GET)
	public void listGET() throws Exception {
		mylog.debug("/board/list 호출 -> DB 정보 가져와서 출력 ");
		
		
	}
	
}

 

전달 받은 정보 x
서비스 - DAO 게시판 리스트
연결되어 있는 뷰 페이지로 정보 전달
페이지 이동(/board/list.jsp)

 

BoardServiceImpl
@Override
	public List<BoardVO> getBoardListALL() throws Exception {
		mylog.debug(" getBoardListAll() - DAO 호출 (결과 리턴받기) ");
		
		return dao.getBoardListAll();
	}

 

BoardService
// 게시판 글 목록 (All)
	public List<BoardVO> getBoardListALL() throws Exception;

 

 

BoardDAO (interface)
// 게시판 목록 (ALl)
	public List<BoardVO> getBoardListAll() throws Exception;

 

BoardDAOImpl
@Override
	public List<BoardVO> getBoardListAll() throws Exception {
	//	mylog.debug("getBoardListAll 호출");
		List<BoardVO> boardList = sqlSession.selectList(NAMESPACE+".listAll");
		//mylog.debug(boardList.size()+"");
		
		return boardList;
	}

 

 

boardMapper

<!-- 게시판 전체목록(all) -->
<select id="listAll" resultType="BoardVO">
	select * from tbl_board

</select>

 

 

 

BoardController

// http://localhost:8080/board/list
	@RequestMapping(value ="/list", method = RequestMethod.GET)
	public void listGET(Model model,@ModelAttribute("result") String result) throws Exception {
		mylog.debug("/board/list 호출 -> DB 정보 가져와서 출력 ");
		
		// 전달 받은 정보 x 
	
		// 서비스 - DAO 게시판 리스트 
		List<BoardVO> boardList = service.getBoardListALL();
		// 연결되어 있는 뷰 페이지로 정보 전달 (Model 객체 생성해야됨) -> 메서드 매개변수 자리에 함 (listGET() 옆에)
		model.addAttribute("boardList", boardList);
		// 페이지 이동 
	}

정보 전달 받기 

 

 

 

list.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ include file="../include/header.jsp" %>

	<h1>/board/list.jsp</h1>
	
<%-- 	${boardList } --%>
	
	${result }
	request : ${requestScope.result }
	session : ${sessionScope.result }
	param   : ${param.result } 
	
	
	<div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Bordered Table</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-bordered">
                <tbody><tr>
                  <th style="width: 40px">번호</th>
                  <th>제목</th>
                  <th>작성자</th>
                  <th>작성일</th>
                  <th style="width: 60px">조회수</th>
                </tr>
                
                
                
                <c:forEach var="boardList" items="${boardList }">
                <tr>
                  <td>${vo.bno }</td>
                  <td>${vo.title }</td>
                  <td>${vo.write }</td>
                  <td>
                  	<fmt:formatDate value="${vo.regdate }" type="both"/>
                  </td>
                    
                  <td><span class="badge bg-red">${vo.viewcnt }</span></td>
                </tr>
               </c:forEach>
               
               
              </tbody></table>
            </div>
            <!-- /.box-body -->
            <div class="box-footer clearfix">
              <ul class="pagination pagination-sm no-margin pull-right">
                <li><a href="#">«</a></li>
                <li><a href="#">1</a></li>
                <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">»</a></li>
              </ul>
            </div>
          </div>
          
          <!-- el 표현식 데이터를 자바 스크립트로 보내기 (DB에서 만든 데이터도 사용가능) (ajax 호출) -->
          <script type="text/javascript">
          //alert('${result }');
          var reesult = '${result}';
          if(result == 'createOK'){
          	alert("글쓰기 완료");
          }
          
          </script>
          
          
<%@ include file="../include/footer.jsp" %>
728x90
반응형

'Spring > Spring' 카테고리의 다른 글

1222 Spring 페이징처리 게시판목록  (0) 2022.12.22
1220 Spring - AOP(Aspect Oriented Programming)  (0) 2022.12.20
1214 Spring - 게시판 글쓰기  (0) 2022.12.14
1213 Spring 프로젝트 생성 & AdminLTE2  (2) 2022.12.13
1206 Spring  (0) 2022.12.06