- 1 <?xml version="1.0" encoding="UTF-8"?>
- 2 <beans xmlns="http://www.springframework.org/schema/beans"
- 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- 4 xmlns:p="http://www.springframework.org/schema/p"
- 5 xmlns:context="http://www.springframework.org/schema/context"
- 6 xmlns:mvc="http://www.springframework.org/schema/mvc"
- 7 xmlns:task="http://www.springframework.org/schema/task"
- 8 xsi:schemaLocation="
- 9 http://www.springframework.org/schema/beans
- 10 http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
- 11 http://www.springframework.org/schema/context
- 12 http://www.springframework.org/schema/context/spring-context-4.2.xsd
- 13 http://www.springframework.org/schema/mvc
- 14 http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
- 15 http://www.springframework.org/schema/task
- 16 http://www.springframework.org/schema/task/spring-task-4.2.xsd">
- 17
- 18 <!-- 扫描路径 -->
- 19 <context:component-scan base-package="com.test.controller" >
- 20 <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
- 21 </context:component-scan>
- 22
- 23 <!-- 配置根视图 -->
- 24 <mvc:view-controller path="/" view-name="index"/>
- 25
- 26 <!-- 激活基于注解的配置 @RequestMapping, @ExceptionHandler,数据绑定 ,@NumberFormat ,
- 27 @DateTimeFormat ,@Controller ,@Valid ,@RequestBody ,@ResponseBody等 -->
- 28 <mvc:annotation-driven />
- 29
- 30 <!-- 静态资源配置 -->
- 31 <mvc:resources location="/assets/" mapping="/assets/**"></mvc:resources>
- 32
- 33 <!-- 视图层配置 -->
- 34 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- 35 <property name="prefix" value="/WEB-INF/pages/"/>
- 36 <property name="suffix" value=".jsp"/>
- 37 </bean>
- 38
- 39 </beans>
来源: