gpt4 book ai didi

httl.web.WebEngine类的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 23:27:05 27 4
gpt4 key购买 nike

本文整理了Java中httl.web.WebEngine类的一些代码示例,展示了WebEngine类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebEngine类的具体详情如下:
包路径:httl.web.WebEngine
类名称:WebEngine

WebEngine介绍

[英]WebEngine (Integration, Singleton, ThreadSafe)
[中]WebEngine(集成、单例、线程安全)

代码示例

代码示例来源:origin: httl/httl

public static String getTemplateSuffix() {
  if (getServletContext() == null) {
    return ".httl";
  }
  return getEngine().getProperty("template.suffix", new String[]{".httl"})[0];
}

代码示例来源:origin: com.github.httl/httl

public static String getTemplateSuffix(ServletContext servletContext) {
  setServletContext(servletContext);
  return getTemplateSuffix();
}

代码示例来源:origin: httl/httl

public void doFilter(HttpServletRequest request, HttpServletResponse response,
    FilterChain chain) throws IOException, ServletException {
  chain.doFilter(request, response);
  try {
    WebEngine.setRequestAndResponse(request, response);
    WebEngine.getEngine().getTemplate(getTemplatePath(request), request.getLocale()).render(response);
  } catch (ParseException e) {
    throw new ServletException(e.getMessage(), e);
  }
}

代码示例来源:origin: httl/httl

@Override
public boolean checkResource(Locale locale) throws Exception {
  WebEngine.setServletContext(getServletContext());
  return WebEngine.getEngine().hasResource(getUrl(), locale);
}

代码示例来源:origin: httl/httl

public void init(FilterConfig config) throws ServletException {
  suffix = WebEngine.getTemplateSuffix(config.getServletContext());
}

代码示例来源:origin: httl/httl

public static void setRequest(HttpServletRequest request) {
  if (request != null && request.getSession() != null) {
    setServletContext(request.getSession().getServletContext());
  }
  ServletResolver.setRequest(request);
}

代码示例来源:origin: httl/httl

public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  try {
    WebEngine.setRequestAndResponse(request, response);
    WebEngine.getEngine().getTemplate(getTemplatePath(request), request.getLocale()).render(response);
  } catch (ParseException e) {
    throw new ServletException(e.getMessage(), e);
  }
}

代码示例来源:origin: httl/httl

WebEngine.setServletContext(servletContext);
  try {
    if (WebEngine.getEngine().hasResource(templateName)) {
      template = WebEngine.getEngine().getTemplate(templateName);
      break;

代码示例来源:origin: httl/httl

@Override
public void init() throws ServletException {
  suffix = WebEngine.getTemplateSuffix(getServletContext());
}

代码示例来源:origin: com.github.httl/httl

public static void setRequest(HttpServletRequest request) {
  if (request != null && request.getSession() != null) {
    setServletContext(request.getSession().getServletContext());
  }
  ServletResolver.setRequest(request);
}

代码示例来源:origin: httl/httl

@Override
public void render() {
  try {
    WebEngine.setRequestAndResponse(request, response);
    WebEngine.getEngine().getTemplate(this.view, request.getLocale()).render(response);
  } catch (Exception e) {
    throw new RenderException(e.getMessage(), e);
  }
}

代码示例来源:origin: com.github.httl/httl

public static String getTemplateSuffix() {
  if (getServletContext() == null) {
    return ".httl";
  }
  return getEngine().getProperty("template.suffix", new String[] {".httl"})[0];
}

代码示例来源:origin: httl/httl

public static String getTemplateSuffix(ServletContext servletContext) {
  setServletContext(servletContext);
  return getTemplateSuffix();
}

代码示例来源:origin: httl/httl

protected String getTemplatePath(String path, HttpServletRequest request) {
    String ext = WebEngine.getTemplateSuffix();
    if (Strings.isBlank(path)) { // 空路径,采用默认规则
      path = Files.renameSuffix(Mvcs.getRequestPath(request), ext);
      if (! path.startsWith("/")) {
        path = "/" + path;
      }
    } else if (path.charAt(0) == '/') { // 绝对路径 : 以 '/' 开头的路径不增加 '/WEB-INF'
      if (! path.toLowerCase().endsWith(ext)) {
        path += ext;
      }
    } else { // 包名形式的路径
      path = path.replace('.', '/') + ext;
    }
    return path;
  }
}

代码示例来源:origin: httl/httl

public static Engine getEngine() {
  if (ENGINE == null) {
    Object request = Context.getContext().get("request");
    if (request instanceof HttpServletRequest && ((HttpServletRequest) request).getSession() != null) {
      setServletContext(((HttpServletRequest) request).getSession().getServletContext());
    } else {
      setServletContext(ServletLoader.getAndCheckServletContext());
    }
  }
  return ENGINE;
}

代码示例来源:origin: httl/httl

@Override
protected void renderMergedTemplateModel(Map<String, Object> model,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
  WebEngine.setRequestAndResponse(request, response);
  WebEngine.getEngine().getTemplate(getUrl(), request.getLocale(), model).render(model, response);
}

代码示例来源:origin: httl/httl

public boolean exists(String templateName) {
  if (WebEngine.getServletContext() == null) {
    return templateName.endsWith(getTemplateSuffix());
  }
  return WebEngine.getEngine().hasResource(getTemplatePath(templateName));
}

代码示例来源:origin: httl/httl

public void afterPropertiesSet() throws Exception {
  WebEngine.setServletContext(getServletContext());
  if (getSuffix() == null || getSuffix().length() == 0) {
    super.setSuffix(WebEngine.getTemplateSuffix());
  }
}

代码示例来源:origin: httl/httl

public String getViewExtension() {
  return WebEngine.getTemplateSuffix(JFinal.me().getServletContext());
}

代码示例来源:origin: com.github.httl/httl

public static Engine getEngine() {
  if (ENGINE == null) {
    Object request = Context.getContext().get("request");
    if (request instanceof HttpServletRequest && ((HttpServletRequest) request).getSession() != null) {
      setServletContext(((HttpServletRequest) request).getSession().getServletContext());
    } else {
      setServletContext(ServletLoader.getAndCheckServletContext());
    }
  }
  return ENGINE;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com