7.3 CacheInterceptor
上例中的用法将使用actionKey作为cacheName,在使用之前需要在ehcache.xml中配置以actionKey命名的cache如:<cache name="/blog/list" …>,注意actionKey作为cacheName配置时斜杠”/”不能省略。此外CacheInterceptor还可以与CacheName 注解配合使用,以此来取代默认的actionKey作为cacheName,以下是示例代码:
- @Before(CacheInterceptor.class)@CacheName("blogList")public void list() { List<Blog> blogList = Blog.dao.find("select * from blog"); setAttr("blogList", blogList); render("blog.html");}