[Spring MVC]ModelAndViewクラスのサンプル

書式
new ModelAndView(xxxx)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@Controller
public class UserController {
@RequestMapping(value="/create",method = RequestMethod.GET)
public ModelAndView create(){
ModelAndView modelAndView = new ModelAndView("userMsg");
modelAndView.addObject("username","test user name");
modelAndView.addObject("addr","test address");
return modelAndView;
}
}
@Controller public class UserController { @RequestMapping(value="/create",method = RequestMethod.GET) public ModelAndView create(){ ModelAndView modelAndView = new ModelAndView("userMsg"); modelAndView.addObject("username","test user name"); modelAndView.addObject("addr","test address"); return modelAndView; } }
@Controller
public class UserController {

  @RequestMapping(value="/create",method = RequestMethod.GET)
  public ModelAndView create(){
        ModelAndView modelAndView = new ModelAndView("userMsg");
      modelAndView.addObject("username","test user name");
      modelAndView.addObject("addr","test address");
      return modelAndView;
  }
}

 

SpringMVC

Posted by arkgame