2016-10-13 9 views
1

私は学習の学生、特にJavaスプリングフレーム(現在は)です。ここにマッピングされていないRequestMappingHandlerMappingの理由はありますか?

私はmybatisを使って学んだことについて、(与えられた練習と一緒に)レビューしています。 私はこれに追いつくのにかなり苦労しています(先生、あまりにも速く)

私がしようとしているのは、会社の従業員のリストを取得する簡単なグラフでページを取得することですチャート。

が、私は(実際の作業を行うために行くもの)リンク上でそれを実行し、クリックしようとすると、私はこれを取得:

がPageNotFoundをWARN - マッピングがURI [/ spring_mvc13_batisTest /リスト]でHTTPリクエストが見つかりません「dispatcherServlet」という名前のDispatcherServletで

404ページのエラーメッセージ。

これは「私のpom.xml

http://maven.apache.org/xsd/maven-4.0.0.xsdです> 4.0.0 org.springframework.samples.service.service spring_mvc13_batisTest 0.0.1-SNAPSHOT 戦争

<properties> 

    <!-- Generic properties --> 
    <java.version>1.6</java.version> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 

    <!-- Web --> 
    <jsp.version>2.2</jsp.version> 
    <jstl.version>1.2</jstl.version> 
    <servlet.version>2.5</servlet.version> 


    <!-- Spring --> 
    <spring-framework.version>4.1.3.RELEASE</spring-framework.version> 

    <!-- Hibernate/JPA --> 
    <hibernate.version>4.2.1.Final</hibernate.version> 

    <!-- Logging --> 
    <logback.version>1.0.13</logback.version> 
    <slf4j.version>1.7.5</slf4j.version> 

    <!-- Test --> 
    <junit.version>4.11</junit.version> 

</properties> 

<dependencies> 

    <!-- Spring MVC --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>${spring-framework.version}</version> 
    </dependency> 

    <!-- Other Web dependencies --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jstl</artifactId> 
     <version>${jstl.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>${servlet.version}</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet.jsp</groupId> 
     <artifactId>jsp-api</artifactId> 
     <version>${jsp.version}</version> 
     <scope>provided</scope> 
    </dependency> 

    <!-- Spring and Transactions --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>${spring-framework.version}</version> 
    </dependency> 

    <!-- Logging with SLF4J & LogBack --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>${slf4j.version}</version> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>ch.qos.logback</groupId> 
     <artifactId>logback-classic</artifactId> 
     <version>${logback.version}</version> 
     <scope>runtime</scope> 
    </dependency> 

    <!-- Hibernate --> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <version>${hibernate.version}</version> 
    </dependency> 


    <!-- Test Artifacts --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-test</artifactId> 
     <version>${spring-framework.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>${junit.version}</version> 
     <scope>test</scope> 
    </dependency> 

    <!-- mariadb jdbc --> 
    <dependency> 
     <groupId>org.mariadb.jdbc</groupId> 
     <artifactId>mariadb-java-client</artifactId> 
     <version>1.5.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-jdbc</artifactId> 
     <version>1.4.1.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-jdbc</artifactId> 
     <version>4.3.3.RELEASE</version> 
    </dependency> 

    <!-- //10.7-2-0 added --> 
    <dependency> 
     <groupId>commons-dbcp</groupId> 
     <artifactId>commons-dbcp</artifactId> 
     <version>1.4</version> 
    </dependency> 



<!-- MYBATIS --> 
<dependency> 
    <groupId>org.mybatis</groupId> 
    <artifactId>mybatis</artifactId> 
    <version>3.4.1</version> 
</dependency> 

<dependency> 
    <groupId>org.mybatis</groupId> 
    <artifactId>mybatis-spring</artifactId> 
    <version>1.3.0</version> 
</dependency> 


</dependencies> 

私のMVC-config.xmlの

読み取ることになっ
<context:component-scan base-package="pack.controller"/> 

<mvc:annotation-driven /> 


<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <!-- Example: a logical view name of 'showMessage' is mapped to '/WEB-INF/jsp/showMessage.jsp' --> 
     <property name="prefix" value="/WEB-INF/view/"/> 
     <property name="suffix" value=".jsp"/> 
</bean> 

とJavaファイル:batisTestで終わる

package pack.controller; 
import java.util.List; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.context.annotation.ComponentScan; 
import org.springframework.stereotype.Component; 
import org.springframework.ui.Model; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.servlet.ModelAndView; 
import pack.model.SawonDto; 
import pack.model.SawonInter; 
@Component 
@ComponentScan("pack.model") 
public class ListController { 

@Autowired 
private SawonInter inter; 

@RequestMapping(value="list", method= RequestMethod.GET) 
public Model processSelect(Model model){ 
    model.addAttribute("lists", inter.selectList()); 
    return model; 

} 
} 

Github link on my work フォルダには、私がやっているもので、もう一つは教えながら、私はクラスの中に書いてきたものです。あなたのListControllerクラスがあるので、完全な一日とまったく運:(親切

誰が説明するためにこれを開催してアイブ?...

答えて

1

を私がここにある検索してみましたが、私はちょうどそれを得るいけませんまだMVCコントローラを春ではない。あなたは、コントローラに春の@Controllerアノテーションを追加する必要があります。

など。また

import org.springframework.stereotype.Controller; 

@Component 
@ComponentScan("pack.model") 
@Controller 
public class ListController { 

私はあなたのreferences.Hopeその助けのために偉大なSpring MVCのウェブサイトをお勧めします。

https://www.mkyong.com/tutorials/spring-mvc-tutorials/

+0

OMG IM Aバカ:( iがコントローラとしてすべてのこの時間コンポーネントを読み違えるように見える:S が働いていました。うわー...私はこれで一日中苦労していましたが、今は馬鹿げています。 – MrSolid51

+0

ありがとう。そうでなければ、他の誰かがそれを指摘するまで、私は一日中このことを進めずにやっていたでしょう。 – MrSolid51

関連する問題