springmvc三大件的配置
每次请求过来的时候,springmvc就要遍历这个文件,找找看,是哪个类型的HandlerMapping, 是哪个类型的HandlerAdapter。jsp spring mvc这样,执行效率太低了。我们可以在配置文件中配置好。
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.ken.controller" />
<!-- 如果没有显示的配置处理器映射器和处理器适配器, 那么springmvc就会去默认的dispatchServlet.properties中查找,
对应的处理器映射器和处理器适配器去使用, 这样每个请求都要扫描一次它的默认配置文件, 效率非常低,会降低访问速度 -->
<!-- 注解形式的处理器映射器 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean>
<!-- 注解形式的处理器适配器 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"></bean>
</beans>
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-73123-1.html
1和之前的都不卡听卖手机的说个别更新了会卡
爱你