2013-12-15 93 views
4

不允許我創建了一個項目,Spring MVC和我dispatcherServlet.xml文件屬性號碼:前綴這裏

<bean id="jspViewResolver" 
      class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
      p:prefix="/WEB-INF/views/" 
      p:suffix=".jsp" 
      /> 

p:prefixp:suffix是不允許的。我該如何解決這個問題?我用SpringVersion 3.2.3.RELEASE

+0

你如何解決你的問題? – Mikhail

回答

4

您需要添加對命名空間聲明:xmlns:p="http://www.springframework.org/schema/p"

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd"> 

見春參考:Chapter 5.4.2.6 XML shortcut with the p-namespace

+1

** xmlns:p = http://www.springframework.org/schema/p**它已經添加,我發現這個鏈接[http://www.springframework.org/schema/p]也無法解析。這是爲什麼 ? – Shashika

+0

我遇到了同樣的問題。 xmlns:p = springframework.org/schema/p已經添加。 – happyyangyuan

-2

<beans xmlns="http://www.springframework.org/schema/beans" 
 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 
     xmlns:context="http://www.springframework.org/schema/context" 
 
     xmlns:util="http://www.springframework.org/schema/util" 
 
     xmlns:p="http://www.springframework.org/schema/p" 
 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
 
\t  \t \t \t \t \t http://www.springframework.org/schema/beans/spring-beans-4.1.xsd 
 
\t  \t \t \t \t \t http://www.springframework.org/schema/context 
 
     \t \t \t \t \t http://www.springframework.org/schema/context/spring-context-4.1.xsd \t 
 
     \t \t \t \t \t http://www.springframework.org/schema/util 
 
     \t \t \t \t \t http://www.springframework.org/schema/util/spring-util-4.1.xsd \t \t \t \t \t  
 
\t  \t \t \t \t \t ">

+0

你應該解釋你的答案如何解決這個問題,即你需要將spring框架名稱空間添加到你的xml bean定義文件的頂部。特別是你需要的部分是'xmlns:p =「http://www.springframework.org/schema/p」'。請注意,沒有要求您使用p :.這些只是被慣例使用。您可以將XML重寫爲在任何地方使用:只要它們被定義爲映射到相同的XML名稱空間即可。 (這就是爲什麼他們需要被定義。) –