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

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

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

JFinal.getServletContext介绍

暂无

代码示例

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

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

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

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

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

  1. @Override
  2. public ServletContext getServletContext() {
  3. return this.jFinal.getServletContext();
  4. }
  5. @Override

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /***/
  2. public HasorPlugin(final JFinal jFinal, final String mainSettings, final List<Module> moduleList) {
  3. this.jFinal = Hasor.assertIsNotNull(jFinal, "jFinal Context is null.");
  4. AppContext webAppContext = RuntimeListener.getAppContext(this.jFinal.getServletContext());
  5. if (webAppContext != null) {
  6. throw new IllegalStateException("Hasor WebAppContext already exists , please disable the other.");
  7. }
  8. this.listener = new RuntimeListener() {
  9. protected Hasor createAppContext(ServletContext sc) throws Throwable {
  10. return newAppContext(jFinal, mainSettings, moduleList);// 创建WebAppContext
  11. }
  12. };
  13. this.rootFilter = new RuntimeFilter();
  14. }
  15. //

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

  1. public static Map<String, String> genHeaderMapByRequest(HttpServletRequest request) {
  2. Map<String, String> map = new HashMap<>();
  3. AdminTokenVO adminTokenVO = AdminTokenThreadLocal.getUser();
  4. if (adminTokenVO != null) {
  5. User user = User.dao.findById(adminTokenVO.getUserId());
  6. map.put("LoginUserName", user.get("userName").toString());
  7. map.put("LoginUserId", adminTokenVO.getUserId() + "");
  8. }
  9. map.put("IsLogin", (adminTokenVO != null) + "");
  10. map.put("Current-Locale", I18nUtil.getCurrentLocale());
  11. map.put("Blog-Version", ((Map) JFinal.me().getServletContext().getAttribute("zrlog")).get("version").toString());
  12. if (request != null) {
  13. String fullUrl = ZrLogUtil.getFullUrl(request);
  14. if (request.getQueryString() != null) {
  15. fullUrl = fullUrl + "?" + request.getQueryString();
  16. }
  17. if (adminTokenVO != null) {
  18. fullUrl = adminTokenVO.getProtocol() + ":" + fullUrl;
  19. }
  20. map.put("Cookie", request.getHeader("Cookie"));
  21. map.put("AccessUrl", "http://127.0.0.1:" + request.getServerPort() + request.getContextPath());
  22. if (request.getHeader("Content-Type") != null) {
  23. map.put("Content-Type", request.getHeader("Content-Type"));
  24. }
  25. map.put("Full-Url", fullUrl);
  26. }
  27. return map;
  28. }
  29. }

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

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

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

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

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

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

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

  1. private void doStart() throws ServletException {
  2. /** 启动 Hasor 框架*/
  3. this.listener.contextInitialized(new ServletContextEvent(this.jFinal.getServletContext()));
  4. this.appContext = RuntimeListener.getAppContext(this.jFinal.getServletContext());
  5. InnerMap envProp = this.appContext.getInstance(InnerMap.class);
  6. this.rootFilter.init(new InnerFilterConfig(this.jFinal, envProp));
  7. //
  8. /** Hasor 框架停止*/
  9. Hasor.pushShutdownListener(this.appContext.getEnvironment(), new EventListener<Object>() {
  10. public void onEvent(String event, Object eventData) throws Throwable {
  11. stop();
  12. }
  13. });
  14. }
  15. public boolean stop() {

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

  1. @Override
  2. public void render() {
  3. JetEngine engine = JetWebEngineLoader.getJetEngine();
  4. if (engine == null) {
  5. JetWebEngineLoader.setServletContext(JFinal.me().getServletContext());
  6. }
  7. String charsetEncoding = engine.getConfig().getOutputEncoding();
  8. response.setCharacterEncoding(charsetEncoding);
  9. if (response.getContentType() == null) {
  10. response.setContentType("text/html; charset=" + charsetEncoding);
  11. }
  12. JetContext context = new JetWebContext(request, response);
  13. JetTemplate template = engine.getTemplate(view);
  14. try {
  15. template.render(context, response.getOutputStream());
  16. } catch (IOException e) {
  17. throw ExceptionUtils.uncheck(e);
  18. }
  19. }
  20. }

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

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

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

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

相关文章