SpringMVC使用ModelAndView,特别是IDEA的小错误。

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.portlet.ModelAndView;

这两个类中都有ModelAndView,我们应该选取第一个导入。如果你是自动导入的话,那么很可能导入的是第二个,从而跳转报错。
报错的提示如下:
在这里插入图片描述
HTTP Status 404 – Not Found
Type Status Report

Message /WEB-INF/demoViews/mvc/testModelAndView.jsp

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Apache Tomcat/9.0.13

将包改成第一个后,问题解决。
在这里插入图片描述
例子来自——
https://www.bilibili.com/video/av14907450/?p=14

猜你喜欢

转载自blog.csdn.net/w8253497062015/article/details/86525633