春季调度员看不到控制器

时间:2015-05-08 08:59:40

标签: java spring spring-mvc dispatcher web-project

我正在尝试使用Gradle在eclipse上构建一个Spring动态Web项目。我的问题是我的春季调度员没有看到控制器,我不知道为什么。

我的项目是这样的:http://hpics.li/8c7aca3

正如您所看到的,我的控制器没有指定spring检测到它的“s”。

这是我的“web.xml”文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <servlet>
        <servlet-name>springmvcdispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

    </servlet>

    <servlet-mapping>
        <servlet-name>springmvcdispatcher</servlet-name>
        <url-pattern>/</url-pattern>

    </servlet-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/springmvcdispatcher-servlet.xml
        </param-value>

    </context-param>

</web-app>

这是我的春季调度员:

<?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.1.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">

    <context:component-scan base-package="com.nostatikmedia.livelizard.controller"></context:component-scan>
    <context:annotation-config/>
    <bean
        class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"></bean>
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/view/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
    <mvc:annotation-driven/>

</beans>

最后我的控制员:

package com.nostatikmedia.livelizard.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/")
public class MainController {

    @RequestMapping(method=RequestMethod.GET)
    public String indexMethod(Model model){
        System.out.println("**********************************************************");
        return "authentication";
    }

}

当我在tomcat8.0服务器上运行项目时,我收到此消息:

在DispatcherServlet中找不到名为“springmvcdispatcher”的带有URI [/ testproject /]的HTTP请求的映射。

任何人都可以帮助我?

坦克。

0 个答案:

没有答案