import java.util.List;


import org.springframework.stereotype.Controller;

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

import org.springframework.web.servlet.ModelAndView;


@Controller

public class ListActionController{

BoardDAO dao;

public void setDao(BoardDAO dao) {

this.dao = dao;

}


@RequestMapping("/list.do")

public ModelAndView hello() throws Exception {

// TODO Auto-generated method stub

List list=dao.list();

ModelAndView mango=new ModelAndView("hi");

mav.addObject("hi", hi);

return mango;

}

}


--------------------------------------------------

//import org.springframework.web.servlet.mvc.Controller;

//public class ListActionController implements Controller {}

--------------------------------------------------

위 소스를 어노테이션으로 바꾼 문장

import org.springframework.stereotype.Controller;

@Controller

public class ListActionController{}

-----------------------------------------------------------
@Override
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {}
-----------------------------------------------------------
위 소스를 어노테이션으로 바꾼 문장
import org.springframework.web.bind.annotation.RequestMapping;

@RequestMapping("/list.do")

public ModelAndView hello() throws Exception {}


<1.메서드명은 자유롭게,매개변수도 없이 가능하다.>

<2. 반환형은 ModelAndView를 그대로 사용해야한다.>

-----------------------------------------------------------

by 맑은소금 2014. 3. 21. 09:47