2011-10-04 36 views
2

我有處理靜態資源的問題。 這是我的web應用程序 WebAppRoot -resources -CSS -style.css -imahes -jsp -template.jsp -secure -template_secure.jsp 所以 myLocation =資源如何處理資源喜歡圖像,* .css與Spring Mvc

哪有我以中心方式處理資源,例如我把位置放在一個變量中, 在標記中使用這個

我試過了,但我不明白如何使用。

回答

1

如果您使用Spring 3.0.4或更高版本,則可以在應用程序配置中使用< mvc:resources ...>元素,並且不需要創建Controller來爲您處理靜態內容。

這是因爲您指定的靜態內容的位置一樣簡單,並從其中的路徑來訪問它們:

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

它使用MVC命名空間中找到http://static.springsource.org/schema/mvc/spring-mvc.xsd