`

Spring 相关几个备忘

阅读更多

spring中查询list结果集的两种实现:

list = jdbcTemplateDrv.query(querySql, new RowmapperResultReader(DrvInfoFromZhkBeanMaper.class) );

list = jdbcTemplateDrv.query(querySql, new BeanPropertyRowMapper(DrvInfoFromZhkBean.class));

 

RowmapperResultReader存在于2.5之前,该方法需要一个实现了RowMapper接口的bean    

BeanPropertyRowMapper存在于2.5之后,该方法则没有这么多的约束,只要内部参数里的bean与查询语句中的字段相对应即可,方便。    

-------------------------------------------------------------------------------------------------------------

<aop:aspectj-autoproxy />有一个proxy-target-class属性,默认为false,表示使用jdk动态代理织入增强,当配为<aop:aspectj-autoproxy  poxy-target-class="true"/>时,表示使用CGLib动态代理技术织入增强。不过即使proxy-target-class设置为false,如果目标类没有声明接口,则spring将自动使用CGLib动态代理。

---------------------------------------------------------------------------

org.springframework.web.servlet.DispatcherServlet是使用Spring MVC时的Front Controller,初始化applicationContext,spring载入的WebApplicationContext是隶属于此Servlet的(所以spring可以配置多个分别拥有各自环境的DispatcherServlet),因此其他servlet无法获取到该Context。只使用它,肯定会找不到bean定义。

 

web程序必须使用org.springframework.web.context.ContextLoaderListener或org.springframework.web.context.ContextLoaderServlet这两种中的一种来初始化container 

 

---------------------------------------------------------------------------------------------------------------

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics