<context:annotation-config/>
向Spring容器注册AutowiredAnnotationBeanPostProcessor,CommonAnnotationBeanPostProcessor,
PersistenceAnnotationBeanPostProcessor,RequiredAnnotationBeanPostProcessor这4个BeanPostProcessor。
注册这4个BeanPostProcessor的作用,就是为了你的系统能够识别相应的注解。
-对于其他没有在spring容器中注册的bean,它不能起到注册bean的作用。
<context:component-scanbase-package=”xx.xx”/>
可以指定package扫描,
可以自动将带有@Autowired,@component,@service,@Repository等注解的对象注册到spring容器中的功能
隐式地在内部注册了AutowiredAnnotationBeanPostProcessor和CommonAnnotationBeanPostProcessor
-因此当使用<context:component-scan/>后,除非需要使用PersistenceAnnotationBeanPostProcessor和RequiredAnnotationBeanPostProcessor两个Processor的功能(例如JPA等)否则就可以将<context:annotation-config/>移除了。
<context:component-scanbase-package="com.baobaotao">
<context:include-filtertype="regex" expression="com\.baobaotao\.service\..*"/>
<context:exclude-filtertype="aspectj" expression="com.baobaotao.util..*"/>
</context:component-scan>
<mvc:annotation-driven/>标签可简化springmvc的相关配置,默认情况下其会创建并注册实例:
DefaultAnnotationHandlerMapping:处理器映射器@Controller(默认注册)
AnnotationMethodHandlerAdapter-:处理器适配器
StringHttpMessageConverter
ByteArrayHttpMessageConverter
XmlAwareFormHttpMessageConverter
SourceHttpMessageConverter。
FormattingConversionServiceFactoryBean-:ConversionService类型转换
NumberFormatAnnotationFormatterFactory:@NumberFormat格式化
JodaDateTimeFormatAnnotationFormatterFactory::@DateTimeFormat格式化
LocalValidatorFactoryBean:@Valid数据校验
转:
http://m.blog.csdn.net/blog/wzmmao/21990397
分享到:
相关推荐
10. <context:annotation-config /> 11. <!-- 把标记了@Controller注解的类转换为bean --> 12. <context:component-scan base-package="com.mvc.controller" /> 13. <!-- 启动Spring MVC的注解功能,...
<mvc:annotation-driven/> <!-- 视图解析器配置 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name...
<context:annotation-config /> <context:component-scan base-package="com.mvc.*"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component...
<mvc:annotation-driven/> <!-- 资源处理 --> <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/"/> <!-- 其他自定义配置... --> </beans> ``` 通过以上步骤,可以成功搭建一个基于...
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" ...
<mvc:annotation-driven /> <!-- 扫描Controller所在的包 --> <context:component-scan base-package="com.example.controller" /> <!-- 自定义拦截器配置 --> <mvc:interceptors> <bean class=...
<context:annotation-config/> <context:component-scan base-package="com.org.*" /> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property...
<mvc:annotation-driven/> <!-- 配置视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name...
<context:component-scan base-package="com.mvc" /> <mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <mvc:default-servlet-handler /> <aop:config proxy-...
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" ...
<mvc:annotation-driven /> <!-- 处理静态资源 --> <mvc:resources mapping="/resources/**" location="/resources/" /> <!-- 日志配置 --> <bean id="logbackConfigLocation" class="org.springframework.beans....
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" ...
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" ...
<tx:annotation-driven transaction-manager="transactionManager"/> </beans> ``` 以上配置仅为示例,实际项目中可能还需要根据具体需求进行调整和完善。整合SSH框架不仅需要正确配置上述文件,还需要处理好各...
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" ...
<mvc:annotation-driven/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> ...
<mvc:annotation-driven/> <!-- 视图解析器配置 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name=...
</context:component-scan> ``` 这里配置了对`Controller`、`Service`和`Repository`注解的扫描,从而实现了对相应组件的自动装配。 #### 三、数据类型转换配置 在SSM框架中,数据类型转换主要是为了将前端传来的...