向Spring MVC容器中注册的方式

来源:互联网 发布:java登录界面设计代码 编辑:程序博客网 时间:2024/05/17 02:11
向Spring MVC容器中注册的方式:
        1.自定义注册:(手动注册bean)
      <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor "/>  
      <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/> 
    2.注解注册:
       Spring MVC 中常用的几种注解:
        1). <context:annotation-config />
        作用:隐式地向 Spring 容器注册。
 
        2).<context:component-scan base-package="com.yitong.*" >
        作用:配置项不但启用了对指定类包进行扫描以实施注释驱动 Bean 定义的功能,同时还启用了注释驱动自动注入的功能。
        3). <mvc:annotation-driven />
        作用:它会自动注册DefaultAnnotationHandlerMapping 与AnnotationMethodHandlerAdapter 
              DefaultAnnotationHandlerMapping  通过注解,把一个URL映射到Controller类上
              AnnotationMethodHandlerAdapter类,通过注解,把一个URL映射到Controller类的方法上
0 0
原创粉丝点击