Spring with IntelliJ attribute p:prefix is not allowed here

Viewed 1068

Please help I need to surpass this problem: enter image description here I have no idea of how to solve this problem.

Snippet of code:

<?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>

Now for the second try: enter image description here

2 Answers

It should be like this :

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>

The problem is you are using the wrong class in the bean.

It is not "org.springframework.web.servlet.view.InternalResourceView"

It is ""org.springframework.web.servlet.view.InternalResourceViewResolver"

Related