2012-10-12 40 views
0

爲什麼我的圖像沒有在我的Spring Web Flow項目中顯示。爲什麼我的圖像沒有出現在我的Spring Web Flow項目中

我有下面的代碼在我的jsp頁面

<img src="<c:url value="/images/getacro.gif" />" alt="Get Adobe Reader" align="top" height="31" width="88"> 

但在我訪問Spring WebFlow項目的圖像是沒有得到顯示在網頁上。所以我檢查了我的Tomcat服務器,我也看到圖像:

的apache-tomcat的-7.0.29/webapps /下注冊/圖像

,但我查了日誌,我看到404錯誤的日誌:

[12月/ 10月/ 2012:15:04:13 -0400] 「GET /Enroll/images/getacro.gif HTTP/1.1」 404 952

,但其上的文件系統。它可能是什麼..我想我的春天設置。

這裏是我的mvc.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:p="http://www.springframework.org/schema/p" 
    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-3.1.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-3.0.xsd"> 

    <mvc:annotation-driven /> 



    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" 
      p:basenames="messages" /> 

    <!-- Declare the Interceptor --> 
    <mvc:interceptors>  
     <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" 
       p:paramName="locale" /> 
    </mvc:interceptors> 

    <bean id="viewResolver" 
     class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
     <property name="viewClass" 
      value="org.springframework.web.servlet.view.JstlView" /> 
     <property name="prefix" value="/WEB-INF/jsp/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 

</beans> 

這裏是我的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    id="WebApp_ID" version="2.5"> 


    <display-name>Enroll</display-name> 
    <welcome-file-list> 
     <welcome-file>index.html</welcome-file> 
     <welcome-file>index.htm</welcome-file> 
     <welcome-file>index.jsp</welcome-file> 
     <welcome-file>default.html</welcome-file> 
     <welcome-file>default.htm</welcome-file> 
     <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 

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

    <servlet> 
     <servlet-name>Resource Servlet</servlet-name> 
     <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class> 
    </servlet> 

    <!-- Map all /resources requests to the Resource Servlet for handling --> 
    <servlet-mapping> 
     <servlet-name>Resource Servlet</servlet-name> 
     <url-pattern>/resources/*</url-pattern> 
    </servlet-mapping> 


    <!-- Spring Security Configuration --> 
    <filter> 
     <filter-name>springSecurityFilterChain</filter-name> 
     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    </filter> 
    <filter-mapping> 
     <filter-name>springSecurityFilterChain</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

</web-app> 
+1

檢查web.xml文件中的映射。 或在spring配置文件中。 insomiac

+0

沒有它的不是。我認爲在我的春季webflow設置中的一些東西正在阻止它 – techsjs2012

+0

你試過在瀏覽器中粘貼完整的URL並檢查圖像是否正確顯示。 ? – insomiac

回答

2

從您的配置文件,因爲你有資源的servlet,我會說試試

<img src="<c:url value="/resources/images/getacro.gif" />" alt="Get Adobe Reader" align="top" height="31" width="88">

+0

這不起作用 – techsjs2012

+0

對不起..我工作......再次感謝! – techsjs2012

相關問題