首页 > 解决方案 > 返回 ModelAndView 不适用于用户定义的函数

问题描述

返回 ModelAndView 对象不适用于用户定义的函数这是我的代码

@Controller
public class HelloController {

    @RequestMapping(value="/welcome",method = RequestMethod.GET)
    public ModelAndView hello(){
        ModelAndView model = new ModelAndView("index");
        model.addObject("msg", "checking ModelAndView return!!!");
        return model;
    }

}

标签: springspring-mvc

解决方案


而不是使用 import org.springframework.web.servlet.ModelAndView;

我用过 import org.springframework.web.portlet.ModelAndView; 这就是问题所在


推荐阅读