1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?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"
- 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">
- <!--扫描控制层组件-->
- <context:component-scan base-package="com.cdxw.controller"></context:component-scan>
- <!--配置Thymeleaf视图解析器-->
- <bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
- <property name="order" value="1"></property>
- <property name="characterEncoding" value="UTF-8"></property>
- <property name="templateEngine">
- <bean class="org.thymeleaf.spring5.SpringTemplateEngine">
- <property name="templateResolver">
- <bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
- <!--视图前缀-->
- <property name="prefix" value="/WEB-INF/templates/"></property>
- <!--视图后缀-->
- <property name="suffix" value=".html"></property>
- <property name="templateMode" value="HTML5"></property>
- <property name="characterEncoding" value="UTF-8"></property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
- <!--开启mvc的注解驱动-->
- <mvc:annotation-driven/>
- <!--
- 视图控制器:为当前的请求直接设置视图名称实现页面跳转
- path:设置处理的请求地址
- view-name:设置请求地址所对应的视图名称
- 若设置视图控制器,则只有视图控制器所设置的请求会被处理,其他的请求将全部404
- 此时必须配置一个标签:<mvc:annotation-driven/>,开启mvc的注解驱动
- -->
- <mvc:view-controller path="/" view-name="index"></mvc:view-controller>
- </beans>
|