BoardController > SPRINGBOOT

본문 바로가기

사이트 내 전체검색

뒤로가기 SPRINGBOOT

BoardController

페이지 정보

작성자 관리자 작성일 24-06-06 12:36 조회 81 댓글 0

본문

package web.controller;


import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.servlet.ModelAndView;


import web.dto.BoardDto;

import web.service.BoardService;


@Controller

//@RequestMapping("") 

public class BoardController {


@Autowired

private BoardService boardService;


@GetMapping("/board/list") 

public ModelAndView openBoardList() throws Exception {

//① 생성자에 값이 존재 한다면 /board/list.html 찾아간다.

ModelAndView mv = new ModelAndView("/board/list");


//② 생성자에 값이 없다면 매핑 값 '/board/list' + '.html' 찾아간다.

//ModelAndView mv = new ModelAndView();


List<BoardDto> list = boardService.selectBoardList();

mv.addObject("list", list);


return mv;

}

}

댓글목록 0

등록된 댓글이 없습니다.


Copyright © dancePKT. All rights reserved.
PC 버전으로 보기