2010-09-30 82 views
4

按照http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources的建議,我希望使用<mvc:resources>來爲我的spring靜態內容提供服務。Spring爲mvc:resources提供靜態內容,無效xsd

我已經嘗試了以下XML,但.xsd文件不包含<mvc:resources>的聲明,我找不到替代的.xsd。我可以忽略eclipse錯誤,但服務器不會由於SAXParseException而啓動。

我哪裏出錯了?

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

    <mvc:resources mapping="/css/**" location="/css/"/> 

</beans> 
+0

我想你可能通過這個link..http也水漲船高://stackoverflow.com/questions/3769888/mvcresources-type-not-resolved雖然它在eclipse中顯示錯誤,但我能夠使用'maven tomcat:run'部署應用程序 – javanoob 2010-10-01 06:23:06

+0

這些雙**表示映射('/ css/** ')。根據我的理解,只有單個*需要包括後面的所有內容? – Abhi 2013-10-04 12:37:56

回答

10

屬性在<mvc:resources>春季3.0.4加入。

編輯即:您只需將Spring 3.0.4添加到您的依賴項,並且一切正常(Eclipse插件中的錯誤標記除外)。在運行時,配置文件由Spring本身解析,因此使用了Spring的內置XSD文件。

+0

但3.0中只有一個.xsd。那麼它怎麼能夠正確編譯? http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd – Steve 2010-09-30 09:46:44

+0

@Steve:架構名稱和位置保持不變,但Spring jar中的實際XSD文件更改爲:https:// src。 springframework.org/svn/spring-framework/tags/spring-framework-3.0.4.RELEASE/org.springframework.web.servlet/src/main/resources/org/springframework/web/servlet/config/spring-mvc- 3.0.xsd – axtavt 2010-09-30 10:01:28

+0

@Steve:更新。 – axtavt 2010-09-30 11:07:32

1

不好於axtavt的迴應,但是有關如何抑制Eclipse錯誤的一些線索。進入項目屬性,然後春→豆類支持→加載NamespaceHandlers和XSD從項目的類路徑[實驗]Eclipse Spring Project Properties Screenshot