0

我试图让一个简单的 EXT JS 表单出现在我的 tomcat 上,但我收到以下错误:

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 调用 restful.css 和 restful.js 类

<%@ 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 正常显示在页面上,但没有出现 EXT 表单,我在网上查看了类似的问题,目前所有解决方案都在我的解决方案中,所以这不是相同的错误。

有人有什么想法吗?

4

2 回答 2

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> 
于 2012-04-17T10:11:18.450 回答
0

试试这个..

<link rel="stylesheet" type="text/css" href="/js/restful.css" />
<script type="text/javascript" src="/js/restful.js"></script>
于 2012-04-17T10:17:47.013 回答