• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AllHttpScopesHashModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中freemarker.ext.servlet.AllHttpScopesHashModel的典型用法代码示例。如果您正苦于以下问题:Java AllHttpScopesHashModel类的具体用法?Java AllHttpScopesHashModel怎么用?Java AllHttpScopesHashModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AllHttpScopesHashModel类属于freemarker.ext.servlet包,在下文中一共展示了AllHttpScopesHashModel类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getTemplate

import freemarker.ext.servlet.AllHttpScopesHashModel; //导入依赖的package包/类
@Override
public Template getTemplate(String name, final Locale locale) throws IOException {
	if (name.equals("templateName") || name.equals("prefix_test_suffix")) {
		return new Template(name, new StringReader("test"), this) {
			@Override
			public void process(Object model, Writer writer) throws TemplateException, IOException {
				assertEquals(Locale.US, locale);
				assertTrue(model instanceof AllHttpScopesHashModel);
				AllHttpScopesHashModel fmModel = (AllHttpScopesHashModel) model;
				assertEquals("myvalue", fmModel.get("myattr").toString());
			}
		};
	}
	else {
		throw new FileNotFoundException();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:FreeMarkerViewTests.java


示例2: getTemplate

import freemarker.ext.servlet.AllHttpScopesHashModel; //导入依赖的package包/类
@Override
public Template getTemplate(String name, final Locale locale) throws IOException {
	if (name.equals("templateName") || name.equals("prefix_test_suffix")) {
		return new Template(name, new StringReader("test")) {
			@Override
			public void process(Object model, Writer writer) throws TemplateException, IOException {
				assertEquals(Locale.US, locale);
				assertTrue(model instanceof AllHttpScopesHashModel);
				AllHttpScopesHashModel fmModel = (AllHttpScopesHashModel) model;
				assertEquals("myvalue", fmModel.get("myattr").toString());
			}
		};
	}
	else {
		throw new FileNotFoundException();
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:18,代码来源:FreeMarkerViewTests.java


示例3: createModel

import freemarker.ext.servlet.AllHttpScopesHashModel; //导入依赖的package包/类
protected TemplateModel createModel(ObjectWrapper objectWrapper, ServletContext servletContext,
		final HttpServletRequest request, final HttpServletResponse response) throws TemplateModelException {
	AllHttpScopesHashModel params = (AllHttpScopesHashModel) super.createModel(objectWrapper, servletContext,
			request, response);
	for (String key : FREEMARKER_EXT_METHODS.keySet()) {
		params.putUnlistedModel(key, FREEMARKER_EXT_METHODS.get(key));
	}
	params.putUnlistedModel("urlEncode", URLENCODEMETHOD);
	params.putUnlistedModel("sleep", SLEEPMETHOD);
	return params;
}
 
开发者ID:gooking,项目名称:yijava,代码行数:12,代码来源:FreemarkerServlet.java


示例4: buildTemplateModel

import freemarker.ext.servlet.AllHttpScopesHashModel; //导入依赖的package包/类
/**
 * Build a FreeMarker template model for the given model Map.
 * <p>The default implementation builds a {@link AllHttpScopesHashModel}.
 * @param model the model to use for rendering
 * @param request current HTTP request
 * @param response current servlet response
 * @return the FreeMarker template model, as a {@link SimpleHash} or subclass thereof
 */
protected SimpleHash buildTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
	AllHttpScopesHashModel fmModel = new AllHttpScopesHashModel(getObjectWrapper(), getServletContext(), request);
	fmModel.put(FreemarkerServlet.KEY_JSP_TAGLIBS, this.taglibFactory);
	fmModel.put(FreemarkerServlet.KEY_APPLICATION, this.servletContextHashModel);
	fmModel.put(FreemarkerServlet.KEY_SESSION, buildSessionModel(request, response));
	fmModel.put(FreemarkerServlet.KEY_REQUEST, new HttpRequestHashModel(request, response, getObjectWrapper()));
	fmModel.put(FreemarkerServlet.KEY_REQUEST_PARAMETERS, new HttpRequestParametersHashModel(request));
	fmModel.putAll(model);
	return fmModel;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:FreeMarkerView.java


示例5: buildTemplateModel

import freemarker.ext.servlet.AllHttpScopesHashModel; //导入依赖的package包/类
protected SimpleHash buildTemplateModel(Map<String, Object> model, WebContext rc) {
	AllHttpScopesHashModel fmModel = new AllHttpScopesHashModel(getObjectWrapper(), rc.getContext(), rc.getRequest());
	fmModel.put(FreemarkerServlet.KEY_JSP_TAGLIBS, this.taglibFactory);
	fmModel.put(FreemarkerServlet.KEY_APPLICATION, this.servletContextHashModel);
	fmModel.put(FreemarkerServlet.KEY_SESSION, buildSessionModel(rc.getRequest(), rc.getResponse()));
	fmModel.put(FreemarkerServlet.KEY_REQUEST, new HttpRequestHashModel(rc.getRequest(), rc.getResponse(), getObjectWrapper()));
	fmModel.put(FreemarkerServlet.KEY_REQUEST_PARAMETERS, new HttpRequestParametersHashModel(rc.getRequest()));
	fmModel.putAll(model);
	return fmModel;
}
 
开发者ID:ketayao,项目名称:fensy,代码行数:11,代码来源:FreeMarkerView.java


示例6: freemarkerTemplateStream

import freemarker.ext.servlet.AllHttpScopesHashModel; //导入依赖的package包/类
protected Result freemarkerTemplateStream(String content, Map<String,Object> params, String cacheFor) {
        StringWriter sw = new StringWriter();

        try {
            if (cacheFor != null) {
                // Set cache header for caching server.
                getResponse().setHeader("X-CB-Cache-Page", cacheFor);
            }

            ClassLoader cl = getClass().getClassLoader();
            Module m = null;

            if (cl instanceof ModuleClassLoader) {
                ModuleClassLoader mcl = (ModuleClassLoader) (cl);
                m = mcl.getModule();
            }

            Configuration conf = FreemarkerHelper.newConfig(app.servletContext(), m);

            getResponse().setLocale(conf.getLocale());
            getResponse().setCharacterEncoding("UTF-8");

            TemplateModel tm = FreemarkerHelper.createModel(ObjectWrapper.DEFAULT_WRAPPER, app.servletContext(),
                app.servletRequest(), app.servletResponse());

            if(params!=null)
                ((AllHttpScopesHashModel)tm).putAll(params);

            app.registryPut(FreemarkerConstant.FREEMARKER_REQUEST_TEMPLATE_MODEL, tm);

            Template t = new Template("templateName", new StringReader(content), conf);


            InjectorProvider saved = Injectors.get();

            t.process(tm, sw);
            Injectors.set(saved);
//            Environment env = t.createProcessingEnvironment(tm, sw);
//            env.setLocale(conf.getLocale());
//            env.process();



        } catch (Throwable th) {
            if (app.isDevPrintErrorMessages()) {
                System.out.println("An error occured while rendering template from string :  " + content);
                th.printStackTrace();
            }

            throw new RuntimeException(th.getMessage(), th);
        }

        return Results.stream("text/html", sw.toString()).bind(params);
    }
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:55,代码来源:ContentController.java



注:本文中的freemarker.ext.servlet.AllHttpScopesHashModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KMSOp类代码示例发布时间:2022-05-23
下一篇:
Java NonSpillableDataBag类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap