这里不允许带有IntelliJ属性p:前缀的Spring

时间:2017-11-13 21:04:38

标签: 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

2 个答案:

答案 0 :(得分:0)

应该是这样的:

<强>调度-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>

答案 1 :(得分:0)

问题是您在Bean中使用了错误的类。

它不是“ org.springframework.web.servlet.view.InternalResourceView”

它是““ org.springframework.web.servlet.view.InternalResourceViewResolver”