본문 바로가기
카테고리 없음

ModelAndView - addObject

by 작은 도구 2013. 2. 15.

addObject

public ModelAndView addObject(String modelName,
                              Object modelObject)
Add an object to the model.

Parameters:
modelName - name of the object to add to the model
modelObject - object to add to the model. May not be null.
Returns:
this ModelAndView, convenient to allow usages like return modelAndView.addObject("foo", bar);


@RequestMapping(value = "/updateForm.do", method = RequestMethod.GET)
 public ModelAndView updateForm(@RequestParam(value="seq",required = true)String seq ){
  ModelAndView mav = new ModelAndView();
   BoardDto board = boardService.select(seq);
   mav.addObject("board_data",board);
   mav.setViewName("update");
  return mav;
 } // end updateForm

 

setViewName

public void setViewName(String viewName)
Set a view name for this ModelAndView, to be resolved by the DispatcherServlet via a ViewResolver. Will override any pre-existing view name or View.