首页 > 代码库 > SpringMvc.xml

SpringMvc.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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">



<!-- 配置@Controller注解扫描 -->
<context:component-scan base-package="com.wolf.controller"></context:component-scan>

<!-- 如果没有显示的配置处理器映射器和处理器适配那么springMvc会去默认的dispatcherServlet.properties中查找,
对应的处理器映射器和处理器适配器去使用,这样每个请求都要扫描一次他的默认配置文件,效率非常低,会降低访问速度,所以要显示的配置处理器映射器和
处理器适配器 -->

<!-- 注解形式的处理器映射器 -->
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean> -->
<!-- 注解形式的处理器适配器 -->
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"></bean> -->

<!-- 配置最新版的注解的处理器映射器 -->
<!-- <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"></bean> -->
<!-- 配置最新版的注解的处理器适配器 -->
<!-- <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"></bean> -->

<!-- 注解驱动:
作用:替我们自动配置最新版的注解的处理器映射器和处理器适配器
-->
<mvc:annotation-driven></mvc:annotation-driven>


<!-- 配置视图解析器
作用:在controller中指定页面路径的时候就不用写页面的完整路径名称了,可以直接写页面去掉扩展名的名称
-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 真正的页面路径 = 前缀 + 去掉后缀名的页面名称 + 后缀 -->
<!-- 前缀 -->
<property name="prefix" value="http://www.mamicode.com/WEB-INF/jsp/"></property>
<!-- 后缀 -->
<property name="suffix" value="http://www.mamicode.com/.jsp"></property>
</bean>
<!-- 配置handler
<bean name = "/queryItems.action" class = "com.wolf.controller.ItemList"></bean>

适配器
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

映射器
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" />

视图解析器 -->
<!--
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="http://www.mamicode.com/org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="http://www.mamicode.com/WEB-INF/jsp/"/>
<property name="suffix" value="http://www.mamicode.com/.jsp"/>
</bean> -->
</beans>

SpringMvc.xml