3

我一直在使用 Spring MVC,到目前为止一切都很好。我决定将 jquery UI 添加到我的项目中,因为我想将 jqgrid 用于我的网格。下面是 webapp 的文件夹结构:

-assets
   +javascript
   +images
   -css
      +jqgrid
      +bootstrap
      -jquery
          -ui-smoothness
             +images
             jquery-ui-1.10.3.custom.min.css /** this file is referecing images  in the image folder above with the css url() method **/ 
        jquery_{versions}.js         
-WEB-INF
   +views
   spring_application_Contexts.xml
   web.xml

在我用于 mvc 的 spring_application_context 中,我有:

<mvc:resources mapping="/images/**" location="/assets/images/" />
<mvc:resources mapping="/styles/**" location="/assets/css/" />
<mvc:resources mapping="/script/**" location="/assets/js/" />

我可以使用以下方法在 jsp 中访问我的文件:

<title><spring:message code="dataview.page.title" /> </title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link href="<spring:url value="/styles/bootstrap/bootstrap.css"/>/" rel="stylesheet">
<link href="<spring:url value="/styles/bootstrap/bootstrap-responsive.css"/>/" rel="stylesheet">
<link href="<spring:url value="/styles/jquery/ui-smoothness/jquery-ui-1.10.3.custom.min.css"/>/" rel="stylesheet">
<link href="<spring:url value="/styles/jqgrid/ui.jqgrid.css"/>/" rel="stylesheet">
<script type="text/javascript" src="<spring:url value="/script/jquery/jquery-1.9.1.min.js"/>"></script>
<script type="text/javascript" src="<spring:url value="/script/jqgrid/jquery.jqGrid.min.js"/>"></script>
<script type="text/javascript" src="<spring:url value="/script/jqgrid/grid.locale-en.js"/>"></script>
<script type="text/javascript" src="<spring:url value="/script/bootstrap/bootstrap.js"/>"></script>

但它抱怨找不到如下文件:

萤火虫屏幕截图

firebug 中的图片 url 有以下类型:

 http://localhost:8080/edowmis/styles/jquery/ui-smoothness/jquery-ui-1.10.3.custom.min.css/images/ui-bg_flat_75_ffffff_40x100.png

图片 url 包含 jquery ui css 路径。

问题在哪里?请帮我解决这个问题,这是我试图弄清楚但徒劳的事情

谢谢

编辑:添加 web.xml 和一些重要的应用程序上下文文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>edowmis</display-name>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>edowmis</param-value>
</context-param>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/edowmis-config.xml</param-value>
</context-param>

<servlet>
    <servlet-name>edowmisDispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/edowmis-config.xml</param-value>
    </init-param>
     <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>edowmisDispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!--Shiro -->
<filter>
    <filter-name>shiroFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
        <param-name>targetFilterLifecycle</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>shiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Shiro End -->


</web-app>

应用程序上下文文件 edowmis-config.xml的片段

 <context:component-scan base-package="net.publichealth.edowmis.web.forms"/>
<context:component-scan base-package="net.publichealth.edowmis.web.security"/>
<context:component-scan base-package="net.publichealth.edowmis.web.util"/>
<context:component-scan base-package="net.publichealth.edowmis.web.service"/>

<import resource="classpath:META-INF/edowmis-mongo-config.xml" />
<import resource="edowmis-security-config.xml" />
<import resource="edowmis-config-mvc.xml" />

波纹管是mvc 上下文的主要部分:edowmis-config-mvc.xml

 <mvc:annotation-driven/>
<context:annotation-config/>
<context:component-scan base-package="net.publichealth.edowmis.web.controllers"/>
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
   <property name="prefix" value="/WEB-INF/mvc/views/"  />
   <property name="suffix" value=".jsp"/>
</bean>

<mvc:resources mapping="/images/**" location="/assets/images/" />
<mvc:resources mapping="/styles/**" location="/assets/css/" />
<mvc:resources mapping="/script/**" location="/assets/js/" />

<bean id="messageSource"
      class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>classpath:messages</value>
        </list>
    </property>
    <property name="defaultEncoding" value="UTF-8" />
</bean>



<bean id="localeChangeInterceptor"
      class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="lang" />
</bean>

<bean id="localeResolver"
      class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>


<bean id="messageConverters"
      class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">

    <property name="messageConverters">
        <list>
            <!-- Message converters -->
            <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.FormHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
            <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
        </list>
    </property>
</bean>

编辑html 的 2 头部分

<head>
<title>Edowmis:: View Data in a Map </title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link href="/edowmis/styles/bootstrap/bootstrap.css/" rel="stylesheet">

<link href="/edowmis/styles/jquery/ui-smoothness/jquery-ui-1.10.3.custom.min.css/" rel="stylesheet">
<link href="/edowmis/styles/jqgrid/ui.jqgrid.css/" rel="stylesheet">
<script type="text/javascript" src="/edowmis/script/jquery/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/edowmis/script/bootstrap/bootstrap.js"></script>
<script type="text/javascript" src="/edowmis/script/jqgrid/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="/edowmis/script/jqgrid/grid.locale-en.js"></script>
<script type="text/javascript" src="/edowmis/script/jqgrid/jquery.contextmenu.js"> </script>
4

0 回答 0