Spring mvc ModelAndView出现404错误

Spring mvc ModelAndView occur 404 Error

使用OSX、Spring mvc 4、intellij

我想使用 ModelAndView。 当我输入 server/board/showArticleList 时,它显示如下所示的 404 错误。 并且服务器没有显示任何错误。

浏览器中的错误消息

Type Status Report

Message /WEB-INF/views/board/showArticleList.jsp

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

控制器

@RequestMapping(value="/board/showArticleList")
public ModelAndView handleRequest(HttpServletRequest arg0,
                                  HttpServletResponse arg1) throws Exception {

    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setView("test");
    modelAndView.addObject("title", "this is title");

    return modelAndView;
}

test.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>testPage</title>
</head>
<body>
    ${title}
</body>
</html>

调度员-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

<mvc:annotation-driven></mvc:annotation-driven>
<context:component-scan base-package="Controller"></context:component-scan>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"></property>
    <property name="suffix" value=".jsp"></property>
</bean>

</beans>

setview 和 RequestMapping 中的视图名称不匹配,因此 Dispatcher Servlet 无法解析视图。