2012-04-17 41 views
0

我試圖得到一個簡單的Ext JS的形式出現在我的tomcat的,但我得到以下錯誤:的Spring MVC與EXT JS錯誤: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> 

我從index.jsp的

<%@ 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> 

目錄結構

this is the structure of my directory

我不能似乎解決了這個錯誤,我的index.jsp是調用restful.css和restful.js類出現在頁面上,但沒有EXT表單出現,我已經在線查看類似的問題,所有解決方案都在我的目前,所以這不是同樣的錯誤。

有沒有人有任何想法?

+0

你能顯示你的目錄結構? – 2012-04-17 10:15:32

+0

我剛剛在那裏添加了目錄結構 – newSpringer 2012-04-17 10:28:38

回答

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 2012-04-17 10:23:26

0

試試這個..

<link rel="stylesheet" type="text/css" href="/js/restful.css" /> 
<script type="text/javascript" src="/js/restful.js"></script> 
相關問題