기록해! 정리해!

어노테이션 기반 MVC 개발 - ModelAndView 를 Model 로 변환 본문

Spring

어노테이션 기반 MVC 개발 - ModelAndView 를 Model 로 변환

zsuling 2022. 9. 26. 14:41
package com.springbook.view;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.springbook.biz.board.BoardVo;
import com.springbook.biz.board.impl.BoardDaoImpl;


@Controller
public class BoardController  {

	@RequestMapping(value="/deleteBoard.do")
	public String deleteBoard(HttpServletRequest request, BoardDaoImpl dao) {

		 int seq= Integer.parseInt(request.getParameter("seq")) ;
		 dao.delete(seq);
		  		 
		return "getBoardList.do";
	}
	
	@RequestMapping(value="/insertBoard.do")
	public String insertBoard(BoardVo vo, BoardDaoImpl dao) {
		 		  
		 dao.insert(vo);		  	
		 
		return "getBoardList.do";
		   
		
	}
	
	
	@RequestMapping(value="/updateBoard.do")
	public String updateBoard(BoardVo vo, BoardDaoImpl dao) {	
		
		   dao.update(vo);	
		   
		return "getBoardList.do";
	}
	
	@RequestMapping(value="/getBoard.do")
	public String getBoard(HttpServletRequest request,BoardDaoImpl dao, Model model) {
		  
		  int seq= Integer.parseInt(request.getParameter("seq")) ;
		  dao.cnt(seq);  		  
		  model.addAttribute("m", dao.getBoard(seq));
		 		  
		return "getBoard.jsp";
	}
	
	@RequestMapping(value="/getBoardList.do")
	public String getBoardList(BoardVo vo , BoardDaoImpl dao, Model model) {
	  		  		 
		 model.addAttribute("li", dao.getBoardList(vo));		 
		  		  
		return "getBoardList.jsp";
	}
	

}
Comments