zoukankan      html  css  js  c++  java
  • SpringMVC配置文件详解

    1.<context:annotation-config/>

    它的作用是隐式的向Spring容器注册
    AutowiredAnnotationBeanPostProcessor,
    CommonAnnotationBeanPostProcessor,
    PersistenceAnnotationBeanPostProcessor,
    RequiredAnnotationBeanPostProcessor
    这4个BeanPostProcessor.注册这4个bean处理器主要的作用是为了你的系统能够识别相应的注解。

    2.<context:component-scan base-package="com.xx.xx" />

    <context:component-scan/>不但启用了对类包进行扫描以实施注释驱动 Bean 定义的功能,同时还启用了注释驱动自动注入的功能(即还隐式地在内部注册了 AutowiredAnnotationBeanPostProcessorCommonAnnotationBeanPostProcessor),因此当使用 <context:component-scan/> 后,就可以将 <context:annotation-config/> 移除了。

    3.<mvc:annotation-driven />

    <mvc:annotation-driven /> 会自动注册DefaultAnnotationHandlerMappingAnnotationMethodHandlerAdapter 两个bean,是spring MVC为@Controllers分发请求所必须的。
    并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson)。
    后面,我们处理响应ajax请求时,就使用到了对json的支持。

  • 相关阅读:
    Remote API(RAPI)之 文件管理
    vue前端框架

    托马斯彩色回旋
    VUE?
    cookie与session
    ajax前后端分离
    djangoIII
    Django少年
    django三板斧
  • 原文地址:https://www.cnblogs.com/bihanghang/p/10031453.html
Copyright © 2011-2022 走看看