Spring2.5 では、コントローラーを次のように記述します。
@Controller
public class HelloWorldController{
@RequestMapping(value="/welcome",method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelAndView model = new ModelAndView("hello");
model.addObject("msg", "hello world");
return model;
}
}
春 3.1:
@RequestMapping(value="/welcome",method = RequestMethod.GET)
public String printWelcomeString(ModelMap model) {
model.addAttribute("message", "hello world);
return "hello";
}
printwelcomeString() 関数は、ModelAndView ではなく文字列を返します。
誰もそれをもっと説明できますか?どのように機能しますか?hello.jsp がモデルを表示する方法を教えてください。ありがとう :)