顯示具有 Spring 標籤的文章。 顯示所有文章
顯示具有 Spring 標籤的文章。 顯示所有文章

2016年1月7日 星期四

How do I get the Session Object in Spring?

How do I get the Session Object in Spring?

// example usage
public static HttpSession session() {
    ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
    return attr.getRequest().getSession(true); // true == allow create
}

2015年12月16日 星期三

Spring 中相關Jar 作用

Spring 中相關Jar包的作用

1.spring-aop-3.2.15.jar  
包含在應用中使用Spring的AOP特性時所需的類。

2.spring-aspects-3.2.15.jar  
提供對AspectJ的支持,以便可以方便的將面向方面的功能集成進IDE中


2015年12月15日 星期二

Spring、Hibernate中使用Ehcache Cache

EhCache是Hibernate的二級Cache技術之一,可以把查詢出來的data存儲在Memory或者disk,節省下次同樣查詢語句再次查詢database,大幅減輕Database壓力;

但這會有個缺點,  若直接從DB改資料時,  因被Query Cache住,  所以重新查詢時,  會查詢到舊有的資料, 需重啟server後,  重新bind資料,  才會取得最新資料,  否則皆需在web介面以系統面方式修改。