如标题,在配置SpringMVC的视图控制器时报错
<mvc:view-controller path="/" view-name="index" />
原因是beans约束不对,正确的beans约束如下(这里只看和SpringMVC控制器有关的):
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:view-controller path="/" view-name="index" />
</beans>
检查两个地方,第一个:
xmlns:mvc="http://www.springframework.org/schema/mvc"
第二个在xsi:schemaLocation里面:
http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd