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

Java JetTemplate类代码示例

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

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



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

示例1: render

import jetbrick.template.JetTemplate; //导入依赖的package包/类
@Override
public boolean render(RequestWeb req, View view)
{
  String viewName = view.name();

  if (! viewName.endsWith(".jetx")) {
    return false;
  }

  try {
    JetTemplate template = _engine.getTemplate(viewName);
    JetContext ctx = new JetContext();
    ctx.putAll(view.map());

    req.type("text/html; charset=utf-8");

    template.render(ctx, req.writer());

    req.ok();
  }
  catch (Exception e) {
    req.fail(e);
  }

  return true;
}
 
开发者ID:baratine,项目名称:baratine,代码行数:27,代码来源:ViewJetbrick.java


示例2: render

import jetbrick.template.JetTemplate; //导入依赖的package包/类
@Override
public void render(Response response, Request request, Object retVal) throws AppRenderException {
    Long start = System.currentTimeMillis();
    String charsetEncoding = engine.getConfig().getOutputEncoding().name();
    response.setCharacterEncoding(charsetEncoding);
    if (response.getContentType() == null) {
        response.setContentType("text/html; charset=" + charsetEncoding);
    }

    try {
        JetTemplate template = engine.getTemplate(retVal.toString());
        JetWebContext context = new JetWebContext(request, response);
        template.render(context, response.getOutputStream());
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    LOGGER.debug("end jetbrick template render : {}", System.currentTimeMillis() - start);
}
 
开发者ID:Teddy-Zhu,项目名称:SilentGo,代码行数:19,代码来源:JetTemplateRender.java


示例3: render

import jetbrick.template.JetTemplate; //导入依赖的package包/类
public void render(HttpServletRequest request, HttpServletResponse response, String viewPath) {
	if (JetWebEngineLoader.unavailable()) {
		JetWebEngineLoader.setServletContext(request.getSession().getServletContext());
	}
	JetContext context = new JetWebContext(request, response);
	if(!view.endsWith(Const.VIEW_EXT)){
		view += Const.VIEW_EXT;
	}
	if(view.endsWith("/" + Const.VIEW_EXT) ){
		return;
	}
	JetTemplate template = JetWebEngineLoader.getJetEngine().getTemplate(view);
	try {
		template.render(context, response.getOutputStream());
	} catch (IOException e) {
		throw ExceptionUtils.uncheck(e);
	}
}
 
开发者ID:mattxia,项目名称:unique-web,代码行数:19,代码来源:JetRender.java


示例4: doExecute

import jetbrick.template.JetTemplate; //导入依赖的package包/类
@Override
protected void doExecute(String location, ActionInvocation ai) throws Exception {
    Map<String, Object> model = ai.getStack().getContext();
    HttpServletRequest request = (HttpServletRequest) model.get(ServletActionContext.HTTP_REQUEST);
    HttpServletResponse response = (HttpServletResponse) model.get(ServletActionContext.HTTP_RESPONSE);

    if (JetWebEngineLoader.unavailable()) {
        ServletContext servletContext = (ServletContext) model.get(ServletActionContext.SERVLET_CONTEXT);
        JetWebEngineLoader.setServletContext(servletContext);
    }

    JetContext context = new JetWebContext(request, response, null);
    context.put("action", ai.getAction());
    context.put("valueStack", model);
    JetTemplate template = JetWebEngineLoader.getJetEngine().getTemplate(location);
    template.render(context, response.getOutputStream());
}
 
开发者ID:subchen,项目名称:jetbrick-template-1x,代码行数:18,代码来源:JetTemplateResult.java


示例5: processView

import jetbrick.template.JetTemplate; //导入依赖的package包/类
@Override
public void processView(ViewEngineContext context) throws ViewEngineException {
	try {
		JetTemplate template = jetEngine.getTemplate(resolveView(context));
		Writer writer = context.getResponse().getWriter();
		template.render(context.getModels(), writer);
	} catch (TemplateException | IOException e) {
		throw new ViewEngineException(e);
	}
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:11,代码来源:JetbrickViewEngine.java


示例6: render

import jetbrick.template.JetTemplate; //导入依赖的package包/类
@Override
public String render(ModelAndView modelAndView) {
    JetTemplate template = jetEngine.getTemplate(modelAndView.getViewName());
    Object model = modelAndView.getModel();
    if (model instanceof Map) {
        Map<String, Object> modelMap = (Map<String, Object>) model;
        JetContext context = new JetContext(modelMap.size());
        context.putAll(modelMap);
        StringWriter writer = new StringWriter();
        template.render(context, writer);
        return writer.toString();
    } else {
        throw new IllegalArgumentException("modelAndView.getModel() must return a java.util.Map");
    }
}
 
开发者ID:perwendel,项目名称:spark-template-engines,代码行数:16,代码来源:JetbrickTemplateEngine.java


示例7: render

import jetbrick.template.JetTemplate; //导入依赖的package包/类
@Override
public void render(HttpServletRequest req, HttpServletResponse resp, Object obj) throws Throwable {
    JetContext context = new JetWebContext(req, resp);
    JetTemplate template = JetWebEngineLoader.getJetEngine().getTemplate(evalPath(req, obj));
    try {
        template.render(context, resp.getOutputStream());
    } catch (IOException e) {
        throw Lang.wrapThrow(e);
    }
}
 
开发者ID:subchen,项目名称:jetbrick-template-1x,代码行数:11,代码来源:JetTemplateView.java


示例8: asInclude

import jetbrick.template.JetTemplate; //导入依赖的package包/类
public static void asInclude(JetPageContext ctx, String relativeName, Map<String, Object> parameters) {
    if (relativeName == null || relativeName.length() == 0) {
        throw new IllegalArgumentException("argument relativeName is null or empty.");
    }
    String file = ctx.getAbsolutionName(relativeName);
    JetTemplate template = ctx.getEngine().getTemplate(file);
    JetContext context = new JetContext(ctx.getContext(), parameters);
    JetWriter writer = ctx.getWriter();
    template.render(context, writer);
}
 
开发者ID:subchen,项目名称:jetbrick-template-1x,代码行数:11,代码来源:JetUtils.java


示例9: asIncludeContent

import jetbrick.template.JetTemplate; //导入依赖的package包/类
public static String asIncludeContent(JetPageContext ctx, String relativeName, Map<String, Object> parameters) {
    if (relativeName == null || relativeName.length() == 0) {
        throw new IllegalArgumentException("argument relativeName is null or empty.");
    }
    String file = ctx.getAbsolutionName(relativeName);
    JetTemplate template = ctx.getEngine().getTemplate(file);
    JetContext context = new JetContext(ctx.getContext(), parameters);

    UnsafeCharArrayWriter os = new UnsafeCharArrayWriter();
    template.render(context, os);
    return os.toString();
}
 
开发者ID:subchen,项目名称:jetbrick-template-1x,代码行数:13,代码来源:JetUtils.java


示例10: main

import jetbrick.template.JetTemplate; //导入依赖的package包/类
public static void main(String[] args) {
    Properties config = new Properties();
    //config.put(JetConfig.COMPILE_TOOL, JdtCompiler.class.getName());
    JetEngine engine = JetEngine.create(config);

    JetTemplate template = engine.createTemplate("是否登录");
    StringWriter out = new StringWriter();
    template.render(new HashMap<String, Object>(), out);
    System.out.println(out.toString());
}
 
开发者ID:subchen,项目名称:jetbrick-template-1x,代码行数:11,代码来源:EncodingTestCase.java


示例11: renderMergedTemplateModel

import jetbrick.template.JetTemplate; //导入依赖的package包/类
@Override
protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
    JetContext context = new JetWebContext(request, response, model);
    JetTemplate template = JetWebEngineLoader.getJetEngine().getTemplate(getUrl());
    template.render(context, response.getOutputStream());
}
 
开发者ID:subchen,项目名称:jetbrick-template-1x,代码行数:7,代码来源:JetTemplateView.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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