1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | package com.douzone.guestbook.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import com.douzone.guestbook.dao.GuestbookDao; import com.douzone.guestbook.vo.GuestbookVo; @Controller public class GuestbookController { @Autowired// private GuestbookDao guestbookDao; /* @ResponseBody @RequestMapping("") public ModelAndView list() { ModelAndView mav = new ModelAndView(); mav.addObject("list", emaillistDao.getList()); mav.setViewName("/WEB-INF/views/list.jsp"); return mav;*/ @RequestMapping("") public String index(Model model) { model.addAttribute("list", guestbookDao.getList()); return "/WEB-INF/views/index.jsp"; } @RequestMapping(value="delete", method=RequestMethod.GET) public String deleteform( @RequestParam(value="no", required=true) Long no) { return "/WEB-INF/views/delete.jsp"; } @RequestMapping(value="/delete", method=RequestMethod.POST) public String delete(GuestbookVo guestbookVo) { guestbookDao.delete(guestbookVo); return "redirect:/"; } @RequestMapping(value="/add", method=RequestMethod.POST) public String add(GuestbookVo guestbookVo) { guestbookDao.insert(guestbookVo); return "redirect:/"; } } | cs |
728x90
'풀스택 > Spring' 카테고리의 다른 글
spring에서의 예외처리 (0) | 2019.02.23 |
---|---|
ViewResolver 설정 (0) | 2019.02.23 |
spring html, css적용 안될때 (0) | 2019.02.23 |
spring 예제 emaillist->emaillist3 (0) | 2019.02.19 |
Spring (0) | 2019.02.14 |
댓글