Spring mvc ModelAndView出现404错误

时间:2018-02-25 12:12:03

标签: spring jsp spring-mvc modelandview

使用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>

0 个答案:

没有答案