Package org.commontemplate.core

Examples of org.commontemplate.core.Template


     
      HttpSession session = this.request.getSession();
      url = session.getServletContext().getRealPath("/")+url;
     
      //获取模板
      Template template = this.engine.getTemplate(url);
      //往上下文中填入数据
      this.context.put("ctxPath", this.request.getContextPath());
      UserRole userPrincipal = this.securityContext.getUserPrincipal();
      this.context.put(SecurityContext.CURRENT_USER_ROlE, userPrincipal);
      this.context.put(SecurityContext.USER_IS_LOGIN, userPrincipal!=null);
      this.context.put("ctx", result);
      this.context.put("xctx",session.getAttribute(HtmlResponseWriter.OPTION_KEY));
     
      template.render(this.context);
     
      String content = this.context.getOut().toString();
     
      //输出到页面
      out.write(content.getBytes("utf-8"));
View Full Code Here


    return "comontemplate.properties";
  }

  protected void serialize(Serializable obj, HttpServletResponse response, String page)
      throws IOException {
    Template template = engine.getTemplate(page);
    Context context = engine.createContext(response.getWriter());
    try {
      context.pushLocalContext(new ModelMap(obj));
      context.setLocale(getLocale());
      template.render(context);
    } finally {
      context.clear();
    }
  }
View Full Code Here

TOP

Related Classes of org.commontemplate.core.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.