[Spring MVC]ModelAndViewと@RequestParamのサンプル

2021年6月14日

Javaコード

  @RequestMapping(value="/create",method = RequestMethod.POST)
  public ModelAndView create(@RequestParam("username") String username){
    ModelAndView modelAndView = new ModelAndView("userMsg");
      modelAndView.addObject("username","値: "+ username);
      modelAndView.addObject("addr","test address");
      return modelAndView;
  }

JSPコード

<form method="post" action="/user/create"
 <input type="text" name="username"
 <input type="submit"

 

SpringMVC

Posted by arkgame