2011-08-31 21 views
7

配置問題:無法找到XML模式命名空間的Spring NamespaceHandler [http://www.springframework.org/schema/MVC]。配置問題:Spring NamespaceHandler for [http://www.springframework.org/schema/mvc]

任何人都可以告訴爲什麼這個錯誤發生? 這是我的配置。

<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" 
xmlns:context="http://www.springframework.org/schema/context" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.0.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> 
+0

沒有ü解決這個問題?要裝什麼罐子版?我也遇到了同樣的問題。 – cherit

回答

2

Spring需要的(運行時)類路徑可以處理mvc:命名空間的NamespaceHandler。這是MvcNamespaceHandler,它位於spring-webmvc-xx.jar。把它放在你的類路徑中。

+0

ya..i已將該jar文件包含在項目類路徑中,但仍然收到相同的錯誤。 –

+0

在項目中 - 是的,但在運行時類路徑? – Bozho

+0

它的工作原理!我在我的pom.xml中添加了' spring-webmvc'這個問題已經消失了。 – eigil

8

@Tijo

您需要檢查幾件事情:

  1. 無論您是使用Spring的版本是3.0。您指的是配置中的spring-beans-3.0.xsd,spring-context-3.0.xsd和spring-mvc-3.0.xsd,因此您需要使用Spring 3.0。* JAR。

  2. 您可能已經在構建路徑中包含所有必需的JAR,很可能是通過將外部JAR添加到構建路徑作爲「引用庫」。您還需要將所有JAR保留在webapp的WEB_INF/lib /文件夾中(將它們直接放在該文件夾中,而不是放在WEB-INF/lib /的子文件夾中)。只有當你的web服務器知道他們。這就是Bozho的意思。

  3. 這是比較微妙的。確保你的WEB-INF/lib文件夾中沒有多個Spring JAR版本。

這是一個需要檢查其他NameSpaceHandler錯誤太多相同的步驟,就像

Unable to locate Spring NamespaceHandler for XML schema namespace 
http://www.springframework.org/schema/context 

Unable to locate Spring NamespaceHandler for XML schema namespace 
[http://www.springframework.org/schema/security] 

希望幫助!

相關問題