2012-04-17 3 views
0

私はTomcat上で表示されるように、単純なEXT JSフォームを取得しようとしていますが、私は次のエラーを取得しています:春MVC:DispatcherServletのnoHandlerFound

17-Apr-2012 10:46:09 org.springframework.web.servlet.DispatcherServlet noHandlerFound 
WARNING: No mapping found for HTTP request with URI [/helloworld/service/web/js /restful.css] in DispatcherServlet with name 'rest' 
17-Apr-2012 10:46:09 org.springframework.web.servlet.DispatcherServlet noHandlerFound 
WARNING: No mapping found for HTTP request with URI [/helloworld/service/web/js/restful.js] in DispatcherServlet with name 'rest' 

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> 

<context-param> 
<param-name>contextConfigLocation</param-name> 
<param-value> 
classpath:/application-context.xml 
</param-value> 
</context-param> 


<!-- This listener will load other application context file in addition to 
     rest-servlet.xml --> 
<listener> 
<listener-class> 
org.springframework.web.context.ContextLoaderListener 
</listener-class> 
</listener> 

<servlet> 
<servlet-name>rest</servlet-name> 
<servlet-class> 
org.springframework.web.servlet.DispatcherServlet 
</servlet-class> 
<load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
<servlet-name>rest</servlet-name> 
<url-pattern>/service/*</url-pattern> 
</servlet-mapping> 

</web-app> 

残り-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> 

<context:component-scan base-package="com.fexco.helloworld.web" /> 

<mvc:annotation-driven /> 

    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> 
      <property name="messageConverters"> 
       <list> 
         <ref bean="jsonConverter" /> 
       </list> 
      </property> 
    </bean> 

    <bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> 
      <property name="supportedMediaTypes" value="application/json" /> 
    </bean> 

    <bean 
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <property name="prefix"> 
     <value>/</value> 
    </property> 
    <property name="suffix"> 
     <value>.jsp</value> 
    </property> 
</bean> 

私は、ディレクトリ構造が、私はこのエラーを解決するように見えるカント

this is the structure of my directory

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 

<%@ page contentType="text/html; charset=ISO-8859-1"%> 

<html> 

<head> 
<link rel="stylesheet" type="text/css" href="/webapp/js/restful.css" /> 
<script type="text/javascript" src="/webapp/js/restful.js"></script> 
</head> 

<body> 
<h1>This is used to display EXT objects</h1> 
</body> 

</html> 

index.jspをからrestful.cssとrestful.jsクラスを呼び出しています、私のindex.jspがありますページに表示されますが、EXT形式は表示されません、私は同様の問題をオンラインで見て、すべてのソリューションが現時点で私の瞬間にありますので、これは同じエラーではありません。

誰にもアイデアはありますか?

+0

をすることができます。これを試してみてくださいディレクトリ構造を表示しますか? –

+0

私はちょうどそこにディレクトリ構造を追加しました – newSpringer

答えて

2

現在、静的ファイル(.jsおよび.css)を相対パスで参照しています。これらのファイルの場所は、表示されているページの場所に依存しないため、意味をなさない。

代わりに絶対パスを使用する必要があります。あなたは、アプリケーションのコンテキストパスを(そう、彼らはあなたのアプリケーションがデプロイさに関係なく正しいです)が含ま絶対パスを構築するために<c:url>を使用することができます。

<link rel="stylesheet" type="text/css" href="<c:url value = '/js/restful.css' />" /> 
<script type="text/javascript" src="<c:url value = '/js/restful.js' />"></script> 
+0

まだフォームが画面に表示されていないが、これはとにかくエラーを解決...歓声:) – newSpringer

0

<link rel="stylesheet" type="text/css" href="/js/restful.css" /> 
<script type="text/javascript" src="/js/restful.js"></script> 
関連する問題