国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

JFinal ??? ??? / CacheInterceptor

CacheInterceptor

CacheInterceptor 可以將 action 所需數(shù)據(jù)全部緩存起來,下次請求到來時(shí)如果 cache 存在則 直接使用數(shù)據(jù)并 render,而不會去調(diào)用 action。此用法可使 action 完全不受 cache 相關(guān)代碼所 污染,即插即用,以下是示例代碼:

@Before(CacheInterceptor.class)
public void list() {
List<Blog> blogList = Blog.dao.find("select * from blog"); User user = User.dao.findById(getParaToInt()); setAttr("blogList", blogList);
setAttr("user", user); render("blog.html");
}

上例中的用法將使用 actionKey 作為 cacheName,在使用之前需要在 ehcache.xml 中配置以 actionKey 命名的 cache 如:<cache name="/blog/list" …>,注意 actionKey 作為 cacheName 配置 時(shí)斜杠”/”不能省略。此外 CacheInterceptor 還可以與 CacheName 注解配合使用,以此來取代默認(rèn)的 actionKey 作為actionName,以下是示例代碼:

@Before(CacheInterceptor.class)
@CacheName("blogList")
public void list() {
List<Blog> blogList = Blog.dao.find("select * from blog"); setAttr("blogList", blogList);
render("blog.html");
}

以上用法需要在 ehcache.xml 中配置名為 blogList 的 cache 如:<cache name="blogList" …>。