org.apache.velocity.app.Velocity.getProperty()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.apache.velocity.app.Velocity.getProperty()方法的一些代码示例,展示了Velocity.getProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Velocity.getProperty()方法的具体详情如下:
包路径:org.apache.velocity.app.Velocity
类名称:Velocity
方法名:getProperty

Velocity.getProperty介绍

[英]Get a Velocity Runtime property.
[中]获取Velocity运行时属性。

代码示例

代码示例来源:origin: looly/hutool

/**
   * 加载可用的Velocity中预定义的编码
   */
  private void loadEncoding() {
    String charset = (String) Velocity.getProperty(Velocity.OUTPUT_ENCODING);
    if(StrUtil.isEmpty(charset)) {
      charset = (String) Velocity.getProperty(Velocity.INPUT_ENCODING);
    }
    this.charset = StrUtil.isEmpty(charset) ? CharsetUtil.UTF_8 : charset;
  }
}

代码示例来源:origin: looly/hutool

/**
   * 加载可用的Velocity中预定义的编码
   */
  private void loadEncoding() {
    String charset = (String) Velocity.getProperty(Velocity.OUTPUT_ENCODING);
    if(StrUtil.isEmpty(charset)) {
      charset = (String) Velocity.getProperty(Velocity.INPUT_ENCODING);
    }
    this.charset = StrUtil.isEmpty(charset) ? CharsetUtil.UTF_8 : charset;
  }
}

代码示例来源:origin: looly/hutool

/**
 * 生成文件
 * 
 * @param template 模板
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(Template template, VelocityContext context, String destPath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.OUTPUT_ENCODING).toString(), false);
    merge(template, context, writer);
  } catch (IORuntimeException e) {
    throw new UtilException(e, "Write Velocity content to [{}] error!", destPath);
  } finally {
    IoUtil.close(writer);
  }
}

代码示例来源:origin: looly/hutool

/**
 * 生成文件
 * 
 * @param template 模板
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(Template template, VelocityContext context, String destPath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.OUTPUT_ENCODING).toString(), false);
    merge(template, context, writer);
  } catch (IORuntimeException e) {
    throw new UtilException(e, "Write Velocity content to [{}] error!", destPath);
  } finally {
    IoUtil.close(writer);
  }
}

代码示例来源:origin: cn.hutool/hutool-all

/**
   * 加载可用的Velocity中预定义的编码
   */
  private void loadEncoding() {
    String charset = (String) Velocity.getProperty(Velocity.OUTPUT_ENCODING);
    if(StrUtil.isEmpty(charset)) {
      charset = (String) Velocity.getProperty(Velocity.INPUT_ENCODING);
    }
    this.charset = StrUtil.isEmpty(charset) ? CharsetUtil.UTF_8 : charset;
  }
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 生成文件
 * 
 * @param template 模板
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(Template template, VelocityContext context, String destPath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.OUTPUT_ENCODING).toString(), false);
    merge(template, context, writer);
  } catch (IORuntimeException e) {
    throw new UtilException(e, "Write Velocity content to [{}] error!", destPath);
  } finally {
    IoUtil.close(writer);
  }
}

代码示例来源:origin: com.xiaoleilu/hutool

/**
 * 生成文件
 * 
 * @param template 模板
 * @param context 模板上下文
 * @param destPath 目标路径(绝对)
 */
public static void toFile(Template template, VelocityContext context, String destPath) {
  PrintWriter writer = null;
  try {
    writer = FileUtil.getPrintWriter(destPath, Velocity.getProperty(Velocity.OUTPUT_ENCODING).toString(), false);
    merge(template, context, writer);
  } catch (IOException e) {
    throw new UtilException(StrUtil.format("Write Velocity content to [{}] error!", destPath), e);
  } finally {
    IoUtil.close(writer);
  }
}

相关文章