code/Athena0.0.1/common/Util/NVelocity/VelocityHelper.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Web;
using System.IO;
using NVelocity;
using NVelocity.App;
using NVelocity.Context;
using NVelocity.Runtime;
using Commons.Collections;
using System.Text;
///////////////////////////////////////////////////
//项目名称:腾杰超轻量级开发框架
//开发者:limingzuo
//模块名称和描述:
//最后更新时间:2017/3/5
//日志说明:
//////////////////////////////////////////////
namespace Athena.common.Util
{
/// <summary>
/// NVelocity模板工具类 VelocityHelper
/// </summary>
public class VelocityHelper
{
private VelocityEngine velocity = null;
private IContext context = null;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="templatDir">模板文件夹路径</param>
public VelocityHelper(string templatDir)
{
Init(templatDir);
}
/// <summary>
/// 无参数构造函数
/// </summary>
public VelocityHelper() { }
/// <summary>
/// 初始话NVelocity模块
/// </summary>
public void Init(string templatDir)
{
//创建VelocityEngine实例对象
velocity = new VelocityEngine();
//使用设置初始化VelocityEngine
ExtendedProperties props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, HttpContext.Current.Server.MapPath(templatDir));
//props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, Path.GetDirectoryName(HttpContext.Current.Request.PhysicalPath));
props.AddProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
props.AddProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");
//模板的缓存设置
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, true); //是否缓存
后面还有 95 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
