http://union.suning.com/aas/open/vistorAd.action?userId=124924&webSiteId=12164&adInfoId=6494&adBookId=48681&subUserEx=155412&vistURL=http://www.suning.com

CommonHelper

 public static string RanderHtml(string templateName, object data)
        {
            VelocityEngine vltEngine = new VelocityEngine();
            vltEngine.SetProperty(RuntimeConstants.RESOURCE_LOADER, "file");
            vltEngine.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, System.Web.Hosting.HostingEnvironment.MapPath("~/templates"));
            vltEngine.Init();           
            VelocityContext vltContext = new VelocityContext();
            vltContext.Put("Data", data );

            Template vltTemplate = vltEngine.GetTemplate(templateName);
            System.IO.StringWriter vltWriter = new System.IO.StringWriter();
            vltTemplate.Merge(vltContext, vltWriter);
            string html = vltWriter.GetStringBuilder().ToString();
            return html;
        }

 

posted @ 2015-07-01 08:44  .netpjava  阅读(222)  评论(0编辑  收藏  举报