提示以下错误,调试几个小时,网上搜遍,找不到结果。
错误 3 “NVelocity.Runtime.RuntimeConstants”并不包含“RESOURCE_LOADER”的定义
错误 4 “NVelocity.Runtime.RuntimeConstants”并不包含“FILE_RESOURCE_LOADER_PATH”的定义
以下是我的代码:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using LTP.Common;using System.IO;using NVelocity;
using NVelocity.App;
using NVelocity.Context;
using NVelocity.Runtime;
using Commons.Collections; //创建VelocityEngine实例对象
VelocityEngine velocity = new VelocityEngine(); //使用设置初始化VelocityEngine
ExtendedProperties props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, Server.MapPath(@"\"));
velocity.Init(props); //从文件中读取模板
Template template = velocity.GetTemplate("myTemplate.vm"); //为模板变量赋值
IContext context = new VelocityContext();
context.Put("from", "somewhere");
context.Put("to", "someone");
context.Put("subject", "Welcome to NVelocity");
context.Put("name", "John Doe"); //合并模板
StringWriter writer = new StringWriter();
template.Merge(context, writer);
错误 3 “NVelocity.Runtime.RuntimeConstants”并不包含“RESOURCE_LOADER”的定义
错误 4 “NVelocity.Runtime.RuntimeConstants”并不包含“FILE_RESOURCE_LOADER_PATH”的定义
以下是我的代码:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using LTP.Common;using System.IO;using NVelocity;
using NVelocity.App;
using NVelocity.Context;
using NVelocity.Runtime;
using Commons.Collections; //创建VelocityEngine实例对象
VelocityEngine velocity = new VelocityEngine(); //使用设置初始化VelocityEngine
ExtendedProperties props = new ExtendedProperties();
props.AddProperty(RuntimeConstants.RESOURCE_LOADER, "file");
props.AddProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, Server.MapPath(@"\"));
velocity.Init(props); //从文件中读取模板
Template template = velocity.GetTemplate("myTemplate.vm"); //为模板变量赋值
IContext context = new VelocityContext();
context.Put("from", "somewhere");
context.Put("to", "someone");
context.Put("subject", "Welcome to NVelocity");
context.Put("name", "John Doe"); //合并模板
StringWriter writer = new StringWriter();
template.Merge(context, writer);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货