2012-10-19 105 views
1

當我把下面這存在服務器上的網址,我得到的404錯誤春天圖像文件的訪問原因未找到404

localhost/PDFDemo/resources/jquery/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png 



Error 404--Not Found 

From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1: 

10.4.5 404 Not Found 

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. 

If the server does not wish to make this information available to the client, the status code `403 (Forbidden)` can be used instead. The `410 (Gone)` status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. 

我對JavaScript文件同樣的問題,在網絡之下將解決這個問題。 XML

<mime-mapping> 
     <extension>js</extension> 
     <mime-type>text/javascript</mime-type> 
    </mime-mapping> 

是否有JSP代碼等同和圖像,我可以把contextConfigLocation(如:servlet.xml文件)。

+1

你的Spring調度器servlet映射到什麼路徑? – digitaljoel

+0

值爲'/'。當我將其更改爲'/ *'時,每個頁面上都會出現404。 – tompal18

+1

您是否在您的配置xml文件中聲明瞭'mvc:resources'?請顯示該內容。 –

回答

0

問題是你正在將Spring Dispatcher Servlet映射到根上下文,所以Spring想要處理每個請求(如果你正確配置它,它本身不是問題)。添加如下內容:

<mvc:resources mapping="/resources/**" location="/public-resources/" cache-period="31556926"/> 

修改爲您的環境應該工作。請參閱文檔以允許靜態資源繞過Spring並轉到默認servlet here

您還應該添加到您的配置,以便Spring知道使用默認Servlet。

<mvc:default-servlet-handler/> 

此外,對this question的答案可能會對您有所幫助。

相關問題