`
mini_hu
  • 浏览: 144774 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Velocity模板缓存配置

    博客分类:
  • Java
阅读更多
velocity开启缓存,主要用于线上环境,在velocity.properties中
file.resource.loader.cache = true
file.resource.loader.modificationCheckInterval = -1


拨开读取模板代码:

Template t = getTemplate(stack, velocityManager.getVelocityEngine(), invocation, finalLocation, encoding);

VelocityResult.java :
protected Template getTemplate(ValueStack stack, VelocityEngine velocity, ActionInvocation invocation, String location, String encoding) throws Exception {
        if (!location.startsWith("/")) {
            location = invocation.getProxy().getNamespace() + "/" + location;
        }

        Template template = velocity.getTemplate(location, encoding);

        return template;
    }

VelocityEngine.java
public Template getTemplate(String name, String encoding)
        throws ResourceNotFoundException, ParseErrorException, Exception
    {
        return ri.getTemplate( name, encoding );
    }

RuntimeInstance.java
public Template getTemplate(String name, String  encoding)
        throws ResourceNotFoundException, ParseErrorException, Exception
    {
        requireInitialization();

        return (Template)
                resourceManager.getResource(name,
                    ResourceManager.RESOURCE_TEMPLATE, encoding);
    }

ResourceManagerImpl.java
public Resource getResource(final String resourceName, final int resourceType, final String encoding)
        throws ResourceNotFoundException,
            ParseErrorException,
            Exception
    {
        String resourceKey = resourceType + resourceName;
        Resource resource = globalCache.get(resourceKey);

ResourceCacheImpl.java
public Resource get( Object key )
    {
        return (Resource) cache.get( key );
    }
分享到:
评论

相关推荐

    LMVC升级版 支持Velocity 模板语言

    基本没有配置,开发快速(也可加入注解使用更灵活) 使用缓存机制.提升性能 方便的拦截器处理公共事务 多视图渲染JspModelAndView,XmlModelAndView,TextStreamModelAndView,Velocity),还可自行定义渲染. 方便的验证和...

    NutzWk企业级开源开发框架 v4.1.9

    NutzWk是集成了Shiro权限控制、Ehcache缓存、Redis、Email服务、Quartz定时任务、Lucene搜索引擎、Beetl/Velocity模板引擎等技术的开源企业级开发框架。 NutzWk 3.x 运行环境:1、JDK 82、Tomcat 83、Maven 3.3.94...

    mybatis-plus-generator.rar

    #MyBatis-Plus-Generator ...4. TemplateEnum:模板枚举类,可根据需要选择velocity(*.vm)或者freemarker(*.ftl)模板进行生成 注:大部分配置都已进行注释说明,若需更多自定义配置,请参考官方文档或者源代码。

    Struts2属性文件详解

    该属性设置浏览器是否缓存静态内容.当应用处于开发阶段时,我们希望每次请求都获得服务器的最新响应,则可设置该属性为false. struts.enable.DynamicMethodInvocation 该属性设置Struts 2是否支持动态方法调用,该属性...

    Struts2\constant应用

    -- 设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭 --> <constant name="struts.serve.static.browserCache " value="false" /> <!-- 当struts的配置文件修改后,系统是否自动...

    springboot学习

    chapter3-1-4:使用Velocity模板引擎渲染web视图 chapter3-1-5:使用Swagger2构建RESTful API chapter3-1-6:统一异常处理 chapter3-1-7:使用Java 8中LocalDate等时间日期类的问题解决 chapter3-1-8:扩展XML请求和...

    Spring in Action(第2版)中文版

    14.4.1使用velocity模板 14.4.2使用freemarker 14.5产生非html输出 14.5.1产生excel工作表 14.5.2产生pdf文档 14.5.3开发自定义视图 14.6小结 第15章使用springwebflow 15.1开始springwebflow之旅 15.1.1...

    Spring in Action(第二版 中文高清版).part2

    14.4.1 使用Velocity模板 14.4.2 使用FreeMarker 14.5 产生非HTML输出 14.5.1 产生Excel工作表 14.5.2 产生PDF文档 14.5.3 开发自定义视图 14.6 小结 第15章 使用Spring Web Flow 15.1 开始Spring Web ...

    Spring in Action(第二版 中文高清版).part1

    14.4.1 使用Velocity模板 14.4.2 使用FreeMarker 14.5 产生非HTML输出 14.5.1 产生Excel工作表 14.5.2 产生PDF文档 14.5.3 开发自定义视图 14.6 小结 第15章 使用Spring Web Flow 15.1 开始Spring Web ...

    java开发常用jar包

    commons-beanutils.jar Apache Commons包中的一个,包含了一些Bean工具类类。必须使用的jar包。 commons-collections.jar ...velocity基于java的模板引擎,允许用简单的模板语言来引用java定义的对

    Java Web程序设计教程

    2.1.2配置环境变量 17 >2.2tomcat的下载与安装 19 2.2.1下载并安装tomcat服务器 19 .2.2.2基本配置 22 2.2.3服务器页面介绍 23 2.3eclipse的下载与安装 24 2.3.1eclipse的下载与安装 24 2.3.2熟悉eclipse开发...

    spring boot 全面的样例代码

    - chapter3-1-4:[使用Velocity模板引擎渲染web视图](http://blog.didispace.com/springbootweb/) - chapter3-1-5:[使用Swagger2构建RESTful API](http://blog.didispace.com/springbootswagger2/) - chapter3-1-6...

    spring4.1核心包

    UI方面的用来与模板(Templating)引擎如 Velocity、FreeMarker、JasperReports集成的类, 6. spring-core-4.1.1.RELEASE.jar spring核心包 7. spring-expression-4.1.1.RELEASE.jar spring表达语言 SpEL以"#{...}...

    单点登录源码

    Velocity | 模板引擎 | [http://velocity.apache.org/](http://velocity.apache.org/) ZooKeeper | 分布式协调服务 | [http://zookeeper.apache.org/](http://zookeeper.apache.org/) Dubbo | 分布式服务框架 | ...

    最新最全的spring开发包

    可以找到使用Spring ApplicationContext特性时所需的全部类,JDNI所需的全部类,UI方面的用来与模板(Templating)引擎如 Velocity、FreeMarker、JasperReports集成的类,以及校验Validation方面的相关类。...

    Spring 2.0 开发参考手册

    8.3.1. Context管理和缓存 8.3.2. 测试fixture的依赖注入 8.3.3. 事务管理 8.3.4. 方便的变量 8.3.5. 示例 8.3.6. 运行集成测试 8.4. 更多资源 II. 中间层数据访问 9. 事务管理 9.1. 简介 9.2. 动机 9.3....

    Spring-Reference_zh_CN(Spring中文参考手册)

    8.3.1. Context管理和缓存 8.3.2. 测试fixture的依赖注入 8.3.3. 事务管理 8.3.4. 方便的变量 8.3.5. 示例 8.3.6. 运行集成测试 8.4. 更多资源 II. 中间层数据访问 9. 事务管理 9.1. 简介 9.2. 动机 9.3. 关键抽象 ...

    spring jar 包详解

    可以找到使用Spring ApplicationContext特性时所需的全部类,JDNI所需的全部类,UI方面的用来与模板(Templating)引擎如 Velocity、FreeMarker、JasperReports集成的类,以及校验Validation方面的相关类。...

    spring chm文档

    8.3.1. Context管理和缓存 8.3.2. 测试fixture的依赖注入 8.3.3. 事务管理 8.3.4. 方便的变量 8.3.5. 示例 8.3.6. 运行集成测试 8.4. 更多资源 II. 中间层数据访问 9. 事务管理 9.1. 简介 9.2. 动机 9.3....

    Spring 2.5 jar 所有开发包及完整文档及项目开发实例

    可以找到使用Spring ApplicationContext特性时所需的全部类,JDNI所需的全部类,UI方面的用来与模板(Templating)引擎如 Velocity、FreeMarker、JasperReports集成的类,以及校验Validation方面的相关类。...

Global site tag (gtag.js) - Google Analytics