com.jfinal.core.JFinal.getServletContext()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(173)

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

JFinal.getServletContext介绍

暂无

代码示例

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

/**
 * Create public void afterJFinalStart() in YourJFinalConfig and 
 * use this method in MyJFinalConfig.afterJFinalStart() to set
 * ServletContext for template loading
 */
public static void setTemplateLoadingPath(String path) {
  config.setServletContextForTemplateLoading(JFinal.me().getServletContext(), path);
}

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

public static void init() {
  init(com.jfinal.core.JFinal.me().getServletContext());
}

代码示例来源:origin: zycgit/hasor

@Override
public ServletContext getServletContext() {
  return this.jFinal.getServletContext();
}
@Override

代码示例来源:origin: 94fzb/zrlog

private void clearCache() {
  JFinal.me().getServletContext().removeAttribute(Constants.CACHE_KEY);
}

代码示例来源:origin: 94fzb/zrlog

public List<String> getFiles(String path) {
    List<String> fileList = new ArrayList<>();
    fillFileInfo(PathKit.getWebRootPath() + path, fileList, ".jsp", ".js", ".css", ".html");
    String webPath = JFinal.me().getServletContext().getRealPath("/");
    List<String> strFile = new ArrayList<>();
    for (String aFileList : fileList) {
      strFile.add(aFileList.substring(webPath.length() - 1 + path.length()).replace('\\', '/'));
    }
    //使用字典序
    return new ArrayList<>(new TreeSet<>(strFile));
  }
}

代码示例来源:origin: com.jfinal/jfinal

/**
 * Create public void afterJFinalStart() in YourJFinalConfig and 
 * use this method in MyJFinalConfig.afterJFinalStart() to set
 * ServletContext for template loading
 */
public static void setTemplateLoadingPath(String path) {
  config.setServletContextForTemplateLoading(JFinal.me().getServletContext(), path);
}

代码示例来源:origin: zycgit/hasor

/** 从 JFinal 中获取 AppContext */
public static AppContext getAppContext(JFinal jFinal) {
  return RuntimeListener.getAppContext(Hasor.assertIsNotNull(jFinal, "jFinal Context is null.").getServletContext());
}
//

代码示例来源:origin: zycgit/hasor

public HasorInterceptor(final JFinal jFinal) {
  this.webAppContext = RuntimeListener.getAppContext(jFinal.getServletContext());
  this.webAppContext = Hasor.assertIsNotNull(this.webAppContext, "need HasorPlugin.");
}
public void intercept(Invocation inv) {

代码示例来源:origin: com.jfinal/jfinal

public static void init() {
  init(com.jfinal.core.JFinal.me().getServletContext());
}

代码示例来源:origin: com.github.sogyf/goja-jfinal

public static void init() {
  init(com.jfinal.core.JFinal.me().getServletContext());
}

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

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

代码示例来源:origin: zycgit/hasor

/***/
public HasorPlugin(final JFinal jFinal, final String mainSettings, final List<Module> moduleList) {
  this.jFinal = Hasor.assertIsNotNull(jFinal, "jFinal Context is null.");
  AppContext webAppContext = RuntimeListener.getAppContext(this.jFinal.getServletContext());
  if (webAppContext != null) {
    throw new IllegalStateException("Hasor WebAppContext already exists , please disable the other.");
  }
  this.listener = new RuntimeListener() {
    protected Hasor createAppContext(ServletContext sc) throws Throwable {
      return newAppContext(jFinal, mainSettings, moduleList);// 创建WebAppContext
    }
  };
  this.rootFilter = new RuntimeFilter();
}
//

代码示例来源:origin: 94fzb/zrlog

public static Map<String, String> genHeaderMapByRequest(HttpServletRequest request) {
    Map<String, String> map = new HashMap<>();
    AdminTokenVO adminTokenVO = AdminTokenThreadLocal.getUser();
    if (adminTokenVO != null) {
      User user = User.dao.findById(adminTokenVO.getUserId());
      map.put("LoginUserName", user.get("userName").toString());
      map.put("LoginUserId", adminTokenVO.getUserId() + "");
    }
    map.put("IsLogin", (adminTokenVO != null) + "");
    map.put("Current-Locale", I18nUtil.getCurrentLocale());
    map.put("Blog-Version", ((Map) JFinal.me().getServletContext().getAttribute("zrlog")).get("version").toString());
    if (request != null) {
      String fullUrl = ZrLogUtil.getFullUrl(request);
      if (request.getQueryString() != null) {
        fullUrl = fullUrl + "?" + request.getQueryString();
      }
      if (adminTokenVO != null) {
        fullUrl = adminTokenVO.getProtocol() + ":" + fullUrl;
      }
      map.put("Cookie", request.getHeader("Cookie"));
      map.put("AccessUrl", "http://127.0.0.1:" + request.getServerPort() + request.getContextPath());
      if (request.getHeader("Content-Type") != null) {
        map.put("Content-Type", request.getHeader("Content-Type"));
      }
      map.put("Full-Url", fullUrl);
    }
    return map;
  }
}

代码示例来源:origin: zycgit/hasor

public boolean stop() {
  this.rootFilter.destroy();
  this.listener.contextDestroyed(new ServletContextEvent(jFinal.getServletContext()));
  return true;
}
protected Hasor newAppContext(final JFinal jFinal, String mainSettings, List<Module> moduleList) throws Throwable {

代码示例来源:origin: zycgit/hasor

public HasorHandler(final JFinal jFinal) {
  AppContext appContext = RuntimeListener.getAppContext(jFinal.getServletContext());
  appContext = Hasor.assertIsNotNull(appContext, "need HasorPlugin.");
  this.filter = appContext.getInstance(RuntimeFilter.class);
}
public final void handle(final String target, HttpServletRequest request, HttpServletResponse response, final boolean[] isHandled) {

代码示例来源:origin: febit/wit

public WitRenderFactory(String suffix) {
  this.suffix = suffix;
  this.engineManager
      = new WebEngineManager(JFinal.me().getServletContext())
      .appendProperties(RESOLVERS, "org.febit.wit.support.jfinal.ModelResolver, org.febit.wit.support.jfinal.RecordResolver");
}

代码示例来源:origin: zycgit/hasor

private void doStart() throws ServletException {
  /** 启动 Hasor 框架*/
  this.listener.contextInitialized(new ServletContextEvent(this.jFinal.getServletContext()));
  this.appContext = RuntimeListener.getAppContext(this.jFinal.getServletContext());
  InnerMap envProp = this.appContext.getInstance(InnerMap.class);
  this.rootFilter.init(new InnerFilterConfig(this.jFinal, envProp));
  //
  /** Hasor 框架停止*/
  Hasor.pushShutdownListener(this.appContext.getEnvironment(), new EventListener<Object>() {
    public void onEvent(String event, Object eventData) throws Throwable {
      stop();
    }
  });
}
public boolean stop() {

代码示例来源:origin: subchen/jetbrick-template-1x

@Override
  public void render() {
    JetEngine engine = JetWebEngineLoader.getJetEngine();
    if (engine == null) {
      JetWebEngineLoader.setServletContext(JFinal.me().getServletContext());
    }

    String charsetEncoding = engine.getConfig().getOutputEncoding();
    response.setCharacterEncoding(charsetEncoding);
    if (response.getContentType() == null) {
      response.setContentType("text/html; charset=" + charsetEncoding);
    }

    JetContext context = new JetWebContext(request, response);
    JetTemplate template = engine.getTemplate(view);
    try {
      template.render(context, response.getOutputStream());
    } catch (IOException e) {
      throw ExceptionUtils.uncheck(e);
    }
  }
}

代码示例来源:origin: subchen/jetbrick-template-2x

public JetTemplateRenderFactory() {
  engine = JetWebEngine.create(JFinal.me().getServletContext());
  engine.getGlobalResolver().registerGetterResolver(new JFinalActiveRecordGetterResolver());
}

代码示例来源:origin: zycgit/hasor

return Hasor.create(jFinal.getServletContext())//

相关文章