yyt
8 天以前 0cceb649e1dc443c2a91d26d81eacb0867c96db3
提交 | 用户 | 时间
0cceb6 1 package com.jcdm.generator.util;
Y 2
3 import java.util.Properties;
4 import org.apache.velocity.app.Velocity;
5 import com.jcdm.common.constant.Constants;
6
7 /**
8  * VelocityEngine工厂
9  * 
10  * @author jc
11  */
12 public class VelocityInitializer
13 {
14     /**
15      * 初始化vm方法
16      */
17     public static void initVelocity()
18     {
19         Properties p = new Properties();
20         try
21         {
22             // 加载classpath目录下的vm文件
23             p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
24             // 定义字符集
25             p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8);
26             // 初始化Velocity引擎,指定配置Properties
27             Velocity.init(p);
28         }
29         catch (Exception e)
30         {
31             throw new RuntimeException(e);
32         }
33     }
34 }