java - Spring 具有 IntelliJ 属性 p :prefix is not allowed here

标签 java spring spring-mvc intellij-idea

请帮助我解决这个问题: enter image description here 我不知道如何解决这个问题。

代码片段:

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


    <mvc:annotation-driven/>

    <context:component-scan base-package="basic" />

    <bean class="org.springframework.web.servlet.view.InternalResourceView" p:prefix="/WEB-INF/jsp/"/>

</beans>

现在进行第二次尝试: enter image description here

最佳答案

应该是这样的:

dispatcher-servlet.xml

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


    <mvc:annotation-driven/>

    <context:component-scan base-package="basic" />

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceView" >
        <property name="prefix">
           <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

</beans>

关于java - Spring 具有 IntelliJ 属性 p :prefix is not allowed here,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47273512/

相关文章:

java - apache tomcat服务器的工作

java - 如何添加到以前的 JLabel

java - 我应该如何重定向Spring框架中的第二页

java - JSP 表达式语言在 Apache Tiles 中不起作用

java - 关于 Java 文件加密性能的建议

java - ResultSet.getFloat 返回 0 而不是 NULL

java - Junit 测试 @InjectMocks 类中的异常

java - 带有对象的通用请求接收 double 值而不是整数值

java - Spring JSP : Trouble with spring form with modelAttribute ="" and path =""

java - 使用 spring mvc 提交/绑定(bind)部分对象