2016-08-07 5 views
0

私はすでに多くのスレッドで解決策を探していましたが、何も私のために働いていませんでした。 http://localhost:8080/springMVC/web-app/WEB-INF/index.html以下のエラーが表示されます。org.springframework.web.servlet.PageNotFound noHandlerFound URIを持つHTTPリクエストのマッピングが見つかりませんでした。プロジェクトをmavenプロジェクトとしてデプロイしました

2016年8月7日7時21分35秒PM org.springframework.web.servlet.PageNotFound noHandlerFound

WARNING:URI [/ springMVC /ウェブアプリ/ WEB-INFとのHTTPリクエストが見つかりませんマッピング/ 「MyDemo」という名前のDispatcherServlet内のindex.html]

ここに私のweb.xmlファイルがあります。

<!DOCTYPE web-app PUBLIC 
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd" > 

<web-app> 
<display-name>Archetype Created Web Application</display-name> 
<servlet> 
<servlet-name>MyDemo</servlet-name> 
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet- class> 

<init-param> 
<param-name>contextConfigLocation</param-name> 
<param-value>/WEB-INF/config/servlet-config.xml</param-value> 
</init-param> 
</servlet> 
<servlet-mapping> 
<servlet-name>MyDemo</servlet-name> 
<url-pattern>*.html</url-pattern> 
</servlet-mapping> 

<welcome-file-list> 
<welcome-file>index.html</welcome-file> 
</welcome-file-list> 

</web-app> 

サーブレット-config.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-4.0.xsd 
    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.2.xsd"> 
<mvc:annotation-driven></mvc:annotation-driven> 

<mvc:default-servlet-handler/> 

<context:component-scan base-package="com.demo.controller.*"></context:component-scan> 
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 

<property name="prefix" value="/WEB-INF/jsp/"></property> 

<property name="suffix" value=".jsp"></property> 

</bean> 

</beans> 

MyDemoController.java

package com.demo.controller; 

import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.RequestMapping; 

@Controller 

public class MyDemoController { 

@RequestMapping(value="/index") 
public String getqoute(Model model) 
{ 
    model.addAttribute("random","To be"); 
    return "quote"; 
} 



} 

任意の提案ですか?

+0

あなたのWebアプリケーションにアクセスするために使用しているリンクがわかりにくいようです。 http:// localhost:8080/springMVC/web-app/WEB-INF/index.html - あなたのリンクには本当にweb-appとWEB-INFが必要ですか? http:// localhost:8080/springMVC/index.htmlを試してください。 – asg

+0

@asg [link](http:// localhost:8080/springMVC/index.html)を試してみると、HTTP 404エラーが表示され、コンソールに「MyDemo」の初期化が完了したことが示されています。 –

答えて

0

ベースパッケージ= "com.demo.controller。*">

変更、それは= "com.demo.controller" パッケージをベースにする>

も @RequestMapping( "/インデックスを使用")

関連する問題