属性p:前缀在此处不允许。

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

请注意,原文中的HTML标签已被保留。

你是如何解决你的问题的? - Mikhail
2个回答

4
您需要添加p命名空间声明: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">

请查看Spring参考文档:第5.4.2.6章节使用p命名空间的XML快捷方式


1
xmlns:p=http://www.springframework.org/schema/p 已经被添加,但我发现这个链接 [http://www.springframework.org/schema/p] 也无法解析。那是为什么? - Shashika
我遇到了相同的问题。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 
            http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
            http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-4.1.xsd 
               http://www.springframework.org/schema/util 
               http://www.springframework.org/schema/util/spring-util-4.1.xsd           
            ">


你需要在你的XML beans定义文件顶部添加Spring框架的命名空间,以解决问题。特别是你需要添加的部分是xmlns:p="http://www.springframework.org/schema/p"。请注意,并没有强制要求你使用p:。这只是按照惯例使用的。你可以重写你的XML,到处使用a: - 只要它们被定义为映射到相同的XML命名空间即可。(这就是为什么它们需要被定义的原因。)请解释你的答案如何解决问题。 - Shane Rowatt

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接