springmvc ModelAndView 和 Model

 @RequestMapping("")
    public ModelAndView index(HttpSession session) {
        Object data = session.getAttribute("user");
        ModelAndView view = new ModelAndView("main/index");
        view.addObject("message", "验证失败,正在跳转中...");
        if (data != null) {
            return view;
        } else {
            return view;            
        }
    }
  @RequestMapping(value = "test", method = RequestMethod.GET)
    public String test(Model model) {
        model.addAttribute("parametername", "handsome");
        return "test";
    }

 

posted @ 2015-07-25 21:24  Seaurl  阅读(312)  评论(0编辑  收藏  举报