日食でGradleを使用して、春の動的Webプロジェクトを構築しようとしています。私の問題は、春のディスパッチャーがコントローラーを認識せず、その理由がわからないことです。
私のプロジェクトは次のようなものです: http://hpics.li/8c7aca3
ご覧のとおり、私のコントローラーには、スプリングがそれを検出したことを示す「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 サーバーでプロジェクトを実行すると、次のメッセージが表示されます。
「springmvcdispatcher」という名前の DispatcherServlet で、URI [/testproject/] の HTTP 要求のマッピングが見つかりません。
誰でも私を助けることができますか?
タンク。