没有找到带有URI的HTTP请求的映射无法映射视图

时间:2014-06-05 14:45:25

标签: java spring spring-mvc

我是JSP + Spring的新手,我无法将控制器驱动到我的视野中。

我已经咨询了一些话题,但我仍然没有看到我的错误。 有人能帮助我吗?

文件夹结构:

  • 控制器:br.com.maycon.controller

  • 观看次数:webapp / WEB-INF / views /

的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <display-name>upload-videos</display-name>

    <!-- Página Inicial -->
    <welcome-file-list>
        <welcome-file>views/index.jsp</welcome-file>
    </welcome-file-list>

    <!-- Spring MVC -->
    <servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>
                  org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>*.jsp</url-pattern>
  </servlet-mapping>

</web-app>

MVC-调度-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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd">

    <!-- Declaração dos Controllers -->
    <bean name="/index.jsp" class="br.com.maycon.controller.IndexController" />

    <context:component-scan base-package="br.com.maycon" />

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

</beans>

Controller(IndexController)

package br.com.maycon.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

@Controller
public class IndexController extends AbstractController {

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        System.out.println("Teste Index Controller");

        ModelAndView model = new ModelAndView("index");
        model.addObject("msg", "Olá Mundo, deu certo!");

        return model;
    }

}

Directory strutcture

0 个答案:

没有答案