如下代码:
@RequestMapping("say")
public ModelAndView hello() {
System.out.println("hello is run");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("/WEB-INF/jsp/hello.jsp");
modelAndView.addObject("msg", "hello springmvc...");
return modelAndView;
}
跳转至hello.jsp页面,却报:
image.png
最终发现问题是由于ModelAndView导包错误,太马虎了,记录下!
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.servlet.ModelAndView;(应该使用这个)
网友评论