com.jfinal.core.JFinal Java Examples

The following examples show how to use com.jfinal.core.JFinal. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: APINotFoundHandler.java    From jfinal-api-scaffold with MIT License 6 votes vote down vote up
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
    if (!target.startsWith("/api")) {
        this.nextHandler.handle(target, request, response, isHandled);
        return;
    }
    
    if (JFinal.me().getAction(target, new String[1]) == null) {
        isHandled[0] = true;
        try {
            request.setCharacterEncoding("utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        RenderFactory.me().getJsonRender(new BaseResponse(Code.NOT_FOUND, "resource is not found")).setContext(request, response).render();
    } else {
        this.nextHandler.handle(target, request, response, isHandled);
    }
}
 
Example #2
Source File: JetTemplateRender.java    From jetbrick-template-1x with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #3
Source File: InstallService.java    From zrlog with Apache License 2.0 6 votes vote down vote up
private void insertFirstArticle(Connection connect) throws SQLException {
    String insetLog = "INSERT INTO `log`(`logId`,`canComment`,`keywords`,`alias`,`typeId`,`userId`,`title`,`content`,`plain_content`,`markdown`,`digest`,`releaseTime`,`last_update_date`,`rubbish`,`privacy`) VALUES (1,?,?,?,1,1,?,?,?,?,?,?,?,?,?)";
    try (PreparedStatement ps = connect.prepareStatement(insetLog)) {
        ps.setBoolean(1, true);
        String markdown = IOUtil.getStringInputStream(InstallService.class.getResourceAsStream("/init-blog/" + I18nUtil.getCurrentLocale() + ".md"));
        markdown = markdown.replace("${basePath}", JFinal.me().getContextPath());
        String content = renderMd(markdown);
        ps.setString(2, I18nUtil.getStringFromRes("defaultType"));
        ps.setString(3, "hello-world");
        ps.setString(4, I18nUtil.getStringFromRes("helloWorld"));
        ps.setString(5, content);
        ps.setString(6, new ArticleService().getPlainSearchText(content));
        ps.setString(7, markdown);
        ps.setString(8, ParseUtil.autoDigest(content, Constants.getAutoDigestLength()));
        ps.setObject(9, new java.util.Date());
        ps.setObject(10, new java.util.Date());
        ps.setBoolean(11, false);
        ps.setBoolean(12, false);
        ps.executeUpdate();
    }
}
 
Example #4
Source File: InstallController.java    From zrlog with Apache License 2.0 6 votes vote down vote up
/**
 * 数据库检查通过后,根据填写信息,执行数据表,表数据的初始化
 */
public String install() {
    Map<String, String> dbConn = (Map<String, String>) JFinal.me().getServletContext().getAttribute("dbConn");
    Map<String, String> configMsg = new HashMap<>();
    configMsg.put("title", getPara("title"));
    configMsg.put("second_title", getPara("second_title"));
    configMsg.put("username", getPara("username"));
    configMsg.put("password", getPara("password"));
    configMsg.put("email", getPara("email"));
    if (new InstallService(PathKit.getWebRootPath() + "/WEB-INF", dbConn, configMsg).install()) {
        final ZrLogConfig config = (ZrLogConfig) JFinal.me().getServletContext().getAttribute("config");
        //通知启动插件,配置库连接等操作
        config.installFinish();
        return "/install/success";
    } else {
        setAttr("errorMsg", "[Error-" + TestConnectDbResult.UNKNOWN.getError() + "] - " + I18nUtil.getStringFromRes("connectDbError_" + TestConnectDbResult.UNKNOWN.getError()));
        return "/install/message";
    }
}
 
Example #5
Source File: InstallController.java    From zrlog with Apache License 2.0 6 votes vote down vote up
/**
 * 检查数据库是否可以正常连接使用,无法连接时给出相应的提示
 */
public String testDbConn() {
    Map<String, String> dbConn = new HashMap<>();
    dbConn.put("jdbcUrl", "jdbc:mysql://" + getPara("dbhost") + ":" + getPara("port") + "/" + getPara("dbname")
            + "?" + ZrLogConfig.JDBC_URL_BASE_QUERY_PARAM);
    dbConn.put("user", getPara("dbuser"));
    dbConn.put("password", getPara("dbpwd"));
    dbConn.put("driverClass", "com.mysql.cj.jdbc.Driver");
    TestConnectDbResult testConnectDbResult = new InstallService(PathKit.getWebRootPath() + "/WEB-INF", dbConn).testDbConn();
    if (testConnectDbResult.getError() != 0) {
        setAttr("errorMsg", "[Error-" + testConnectDbResult.getError() + "] - " + I18nUtil.getStringFromRes("connectDbError_" + testConnectDbResult.getError()));
        return index();
    } else {
        JFinal.me().getServletContext().setAttribute("dbConn", dbConn);
        return "/install/message";
    }
}
 
Example #6
Source File: AdminArticlePageController.java    From zrlog with Apache License 2.0 6 votes vote down vote up
public String preview() {
    Integer logId = getParaToInt("id");
    if (logId != null) {
        Log log = new Log().adminFindLogByLogId(logId);
        if (log != null) {
            log.put("lastLog", new Log().findLastLog(logId, I18nUtil.getStringFromRes("noLastLog")));
            log.put("nextLog", new Log().findNextLog(logId, I18nUtil.getStringFromRes("noNextLog")));
            setAttr("log", log.getAttrs());
            TemplateHelper.fillArticleInfo(log, getRequest(), "");
        }
        return getTemplatePath() + "/detail" + ZrLogUtil.getViewExt(new TemplateService().getTemplateVO(JFinal.me().getContextPath(),
                new File(PathKit.getWebRootPath() + getTemplatePath())).getViewType());
    } else {
        return Constants.NOT_FOUND_PAGE;
    }
}
 
Example #7
Source File: UpgradeController.java    From zrlog with Apache License 2.0 6 votes vote down vote up
private CheckVersionResponse getCheckVersionResponse(boolean fetchAble) {
    Plugins plugins = (Plugins) JFinal.me().getServletContext().getAttribute("plugins");
    CheckVersionResponse checkVersionResponse = new CheckVersionResponse();
    for (IPlugin plugin : plugins.getPluginList()) {
        if (plugin instanceof UpdateVersionPlugin) {
            Version version = ((UpdateVersionPlugin) plugin).getLastVersion(fetchAble);
            if (version != null) {
                checkVersionResponse.setUpgrade(true);
                checkVersionResponse.setVersion(version);
            }
        }
    }
    if (checkVersionResponse.getVersion() != null) {
        //不在页面展示SNAPSHOT
        checkVersionResponse.getVersion().setVersion(checkVersionResponse.getVersion().getVersion().replaceAll("-SNAPSHOT", ""));
    }
    return checkVersionResponse;
}
 
Example #8
Source File: AdminInterceptor.java    From zrlog with Apache License 2.0 6 votes vote down vote up
public static void initIndex(HttpServletRequest request) {
    request.setAttribute("previewDb", com.zrlog.web.config.ZrLogConfig.isPreviewDb());

    CheckVersionResponse response = new UpgradeController().lastVersion();
    JFinal.me().getServletContext().setAttribute("lastVersion", response);
    List<Comment> commentList = new Comment().findHaveReadIsFalse();
    if (commentList != null && !commentList.isEmpty()) {
        request.setAttribute("noReadComments", commentList);
        for (Comment comment : commentList) {
            if (StringUtils.isEmpty(comment.get("header"))) {
                comment.set("header", Constants.DEFAULT_HEADER);
            }
        }
    }
    request.setAttribute("lastVersion", response);
    request.setAttribute("zrlog", ZrLogConfig.blogProperties);
    request.setAttribute("system", ZrLogConfig.SYSTEM_PROP);
}
 
Example #9
Source File: BlackListInterceptor.java    From zrlog with Apache License 2.0 6 votes vote down vote up
@Override
public void intercept(Invocation invocation) {
    if (invocation.getController() instanceof BaseController) {
        BaseController baseController = (BaseController) invocation.getController();
        String ipStr = (String) Constants.WEB_SITE.get("blackList");
        if (ipStr != null) {
            Set<String> ipSet = new HashSet<>(Arrays.asList(ipStr.split(",")));
            String requestIP = WebTools.getRealIp(baseController.getRequest());
            if (ipSet.contains(requestIP)) {
                baseController.render(JFinal.me().getConstants().getErrorView(403));
            } else {
                invocation.invoke();
            }
        } else {
            invocation.invoke();
        }
    } else {
        invocation.invoke();
    }
}
 
Example #10
Source File: WarUpdateVersionThread.java    From zrlog with Apache License 2.0 6 votes vote down vote up
private String getWarNameAndBackup() {
    String warName;
    String contextPath = JFinal.me().getServletContext().getContextPath();
    if ("/".equals(contextPath) || "".equals(contextPath)) {
        warName = "/ROOT.war";
    } else {
        warName = contextPath + ".war";
    }
    String backupFolder = new File(PathKit.getWebRootPath()).getParentFile().getParentFile() + File.separator + "backup" + File.separator + new SimpleDateFormat("yyyy-MM-dd_HH_mm").format(new Date()) + File.separator;
    new File(backupFolder).mkdirs();
    FileUtils.moveOrCopyFolder(PathKit.getWebRootPath(), backupFolder, false);
    String warPath = new File(PathKit.getWebRootPath()).getParent() + File.separator + warName;
    if (new File(warPath).exists()) {
        FileUtils.moveOrCopyFolder(warPath, backupFolder, false);
    }
    updateProcessMsg("备份当前版本到 " + backupFolder);
    return warName;
}
 
Example #11
Source File: ProductPageDirective.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String getUrl(int pageNumber, Env env, Scope scope, Writer writer) {
    HttpServletRequest request = JbootControllerContext.get().getRequest();
    String url = request.getRequestURI();
    String contextPath = JFinal.me().getContextPath();

    boolean firstGotoIndex = getPara("firstGotoIndex", scope, false);

    if (pageNumber == 1 && firstGotoIndex) {
        return contextPath + "/";
    }

    // 如果当前页面是首页的话
    // 需要改变url的值,因为 上一页或下一页是通过当前的url解析出来的
    if (url.equals(contextPath + "/")) {
        url = contextPath + "/product/category/index" + JPressOptions.getAppUrlSuffix();
    }

    return DirectveKit.replacePageNumber(url, pageNumber);
}
 
Example #12
Source File: ProductController.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 购买商品
 */
@Before(ProductValidate.class)
public void doBuy() {
    Product product = ProductValidate.getThreadLocalProduct();
    User user = getLoginedUser();
    Long distUserId = CookieUtil.getLong(this, buildDistUserCookieName(product.getId()));
    UserCart userCart = product.toUserCartItem(user.getId(), distUserId, getPara("spec"));

    Object cartId = cartService.save(userCart);

    if (isAjaxRequest()) {
        renderJson(Ret.ok().set("gotoUrl", JFinal.me().getContextPath() + "/ucenter/checkout/" + cartId));
    } else {
        redirect("/ucenter/checkout/" + cartId);
    }
}
 
Example #13
Source File: ArticlePageDirective.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String getUrl(int pageNumber, Env env, Scope scope, Writer writer) {
    HttpServletRequest request = JbootControllerContext.get().getRequest();
    String url = request.getRequestURI();
    String contextPath = JFinal.me().getContextPath();

    boolean firstGotoIndex = getPara("firstGotoIndex", scope, false);

    if (pageNumber == 1 && firstGotoIndex) {
        return contextPath + "/";
    }

    // 如果当前页面是首页的话
    // 需要改变url的值,因为 上一页或下一页是通过当前的url解析出来的
    if (url.equals(contextPath + "/")) {
        url = contextPath + "/article/category/index"
                + JPressOptions.getAppUrlSuffix();
    }
    return DirectveKit.replacePageNumber(url, pageNumber);
}
 
Example #14
Source File: FileUtil.java    From jboot with Apache License 2.0 6 votes vote down vote up
public static String readString(File file) {
    ByteArrayOutputStream baos = null;
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(file);
        baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        for (int len = 0; (len = fis.read(buffer)) > 0; ) {
            baos.write(buffer, 0, len);
        }
        return new String(baos.toByteArray(), JFinal.me().getConstants().getEncoding());
    } catch (Exception e) {
        LogKit.error(e.toString(), e);
    } finally {
        close(fis, baos);
    }
    return null;
}
 
Example #15
Source File: MenuManager.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static List<MenuItem> buildUCenterMenuItems() {

        List<MenuItem> adminMenuItems = new ArrayList<>();
        List<String> allActionKeys = JFinal.me().getAllActionKeys();

        String[] urlPara = new String[1];
        for (String actionKey : allActionKeys) {
            // 只处理后台的权限 和 API的权限
            if (actionKey.startsWith("/ucenter")) {

                Action action = JFinal.me().getAction(actionKey, urlPara);
                if (action == null || excludedMethodName.contains(action.getMethodName())) {
                    continue;
                }

                UCenterMenu uCenterMenu = action.getMethod().getAnnotation(UCenterMenu.class);
                if (uCenterMenu == null) {
                    continue;
                }

                adminMenuItems.add(new MenuItem(uCenterMenu, actionKey));
            }
        }

        return adminMenuItems;
    }
 
Example #16
Source File: MenuManager.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static List<MenuItem> buildAdminMenuItems() {

        List<MenuItem> adminMenuItems = new ArrayList<>();
        List<String> allActionKeys = JFinal.me().getAllActionKeys();

        String[] urlPara = new String[1];
        for (String actionKey : allActionKeys) {

            if (actionKey.startsWith("/admin")) {
                Action action = JFinal.me().getAction(actionKey, urlPara);
                if (action == null || excludedMethodName.contains(action.getMethodName())) {
                    continue;
                }

                AdminMenu adminMenu = action.getMethod().getAnnotation(AdminMenu.class);
                if (adminMenu == null) {
                    continue;
                }

                adminMenuItems.add(new MenuItem(adminMenu, actionKey));
            }
        }

        return adminMenuItems;
    }
 
Example #17
Source File: AddonUtil.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static String readString(InputStream stream) {
    ByteArrayOutputStream baos = null;
    try {
        baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        for (int len = 0; (len = stream.read(buffer)) > 0; ) {
            baos.write(buffer, 0, len);
        }
        return new String(baos.toByteArray(), JFinal.me().getConstants().getEncoding());
    } catch (Exception e) {
        LogKit.error(e.toString(), e);
    } finally {
        CommonsUtils.quietlyClose(baos);
    }
    return null;
}
 
Example #18
Source File: StrUtil.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static String urlEncode(String string) {
    try {
        return URLEncoder.encode(string, JFinal.me().getConstants().getEncoding());
    } catch (UnsupportedEncodingException e) {
        log.error("urlEncode is error", e);
    }
    return string;
}
 
Example #19
Source File: VisitorInterceptor.java    From zrlog with Apache License 2.0 5 votes vote down vote up
/**
 * 方便开发环境使用,将Servlet的Request域的数据转化JSON字符串,配合dev.jsp使用,定制主题更加方便
 *
 * @param controller
 */
private void fullDevData(Controller controller) {
    boolean dev = JFinal.me().getConstants().getDevMode();
    controller.setAttr("dev", dev);
    if (dev) {
        Map<String, Object> attrMap = new LinkedHashMap<>();
        Enumeration<String> enumerations = controller.getAttrNames();
        while (enumerations.hasMoreElements()) {
            String key = enumerations.nextElement();
            attrMap.put(key, controller.getAttr(key));
        }
        controller.setAttr("requestScopeJsonString", Json.getJson().toJson(attrMap));
    }
}
 
Example #20
Source File: TemplateHelper.java    From zrlog with Apache License 2.0 5 votes vote down vote up
static String fullTemplateInfo(Controller controller, boolean reload) {
    if (controller instanceof BaseController) {
        BaseController baseController = (BaseController) controller;
        String basePath = baseController.getTemplatePath();
        controller.getRequest().setAttribute("template", basePath);
        I18nUtil.addToRequest(PathKit.getWebRootPath() + basePath + "/language/", controller.getRequest(), JFinal.me().getConstants().getDevMode(), reload);
        baseController.fullTemplateSetting();
        TemplateHelper.fullInfo(controller.getRequest(), Constants.isStaticHtmlStatus());
        return basePath;
    }
    return Constants.DEFAULT_TEMPLATE_PATH;
}
 
Example #21
Source File: AdminInterceptor.java    From zrlog with Apache License 2.0 5 votes vote down vote up
/**
 * 尝试通过Controller的放回值来进行数据的渲染
 *
 * @param ai
 * @param controller
 * @return true 表示已经渲染数据了,false 表示并未按照约定编写,及没有进行渲染
 */
private boolean tryDoRender(Invocation ai, Controller controller) {
    Object returnValue = ai.getReturnValue();
    if (ai.getMethod().getAnnotation(RefreshCache.class) != null) {
        cacheService.refreshInitDataCache(GlobalResourceHandler.CACHE_HTML_PATH, controller, true);
        if (JFinal.me().getConstants().getDevMode()) {
            LOGGER.info("{} trigger refresh cache", controller.getRequest().getRequestURI());
        }
    }
    boolean rendered = false;
    if (returnValue != null) {
        if (ai.getActionKey().startsWith("/api/admin")) {
            controller.renderJson((Object) ai.getReturnValue());
            rendered = true;
        } else if (ai.getActionKey().startsWith("/admin") && returnValue instanceof String) {
            //返回值,约定:admin 开头的不写模板类型,其他要写全
            if (!returnValue.toString().endsWith(".jsp") && returnValue.toString().startsWith("/admin")) {
                String templatePath = returnValue.toString() + ".ftl";
                if (AdminInterceptor.class.getResourceAsStream(Constants.FTL_VIEW_PATH + templatePath) != null) {
                    controller.render(new FreeMarkerRender(templatePath));
                    rendered = true;
                } else {
                    rendered = false;
                }
            } else {
                controller.render(returnValue.toString());
                rendered = true;
            }
        }
    } else {
        rendered = true;
    }
    return rendered;
}
 
Example #22
Source File: MyI18nInterceptor.java    From zrlog with Apache License 2.0 5 votes vote down vote up
@Override
public void intercept(Invocation inv) {
    if (Constants.IN_JAR) {
        I18nUtil.addToRequest(null, inv.getController().getRequest(), JFinal.me().getConstants().getDevMode(), false);
    } else {
        I18nUtil.addToRequest(PathKit.getRootClassPath(), inv.getController().getRequest(), JFinal.me().getConstants().getDevMode(), false);
    }
    inv.invoke();
}
 
Example #23
Source File: StrUtil.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static String urlRedirect(String redirect) {
    try {
        redirect = new String(redirect.getBytes(JFinal.me().getConstants().getEncoding()), "ISO8859_1");
    } catch (UnsupportedEncodingException e) {
        log.error("urlRedirect is error", e);
    }
    return redirect;
}
 
Example #24
Source File: AdminTemplatePageController.java    From zrlog with Apache License 2.0 5 votes vote down vote up
public String configPage() {
    String templateName = getPara("template");
    setAttr("template", templateName);
    TemplateVO templateVO = templateService.getTemplateVO(JFinal.me().getContextPath(), new File(PathKit.getWebRootPath() + templateName));
    setAttr("templateInfo", templateVO);
    I18nUtil.addToRequest(PathKit.getWebRootPath() + templateName + "/language/", getRequest(), JFinal.me().getConstants().getDevMode(), true);
    String jsonStr = new WebSite().getStringValueByName(templateName + Constants.TEMPLATE_CONFIG_SUFFIX);
    fullTemplateSetting(jsonStr);
    return templateName + "/setting/index" + ZrLogUtil.getViewExt(templateVO.getViewType());
}
 
Example #25
Source File: User.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String getAvatar() {
    String avatar = super.getAvatar();
    if (avatar != null && avatar.toLowerCase().startsWith("http")) {
        return avatar;
    }

    return JFinal.me().getContextPath() +
            (StrUtil.isNotBlank(avatar) ? avatar : DEFAULT_AVATAR);
}
 
Example #26
Source File: StrUtil.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static String urlDecode(String string) {
    try {
        return URLDecoder.decode(string, JFinal.me().getConstants().getEncoding());
    } catch (UnsupportedEncodingException e) {
        log.error("urlDecode is error", e);
    }
    return string;
}
 
Example #27
Source File: FileUtil.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static void writeString(File file, String string) {
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(file, false);
        fos.write(string.getBytes(JFinal.me().getConstants().getEncoding()));
    } catch (Exception e) {
        LogKit.error(e.toString(), e);
    } finally {
        close(fos);
    }
}
 
Example #28
Source File: ZrLogConfig.java    From zrlog with Apache License 2.0 5 votes vote down vote up
/**
 * 设置系统参数到Servlet的Context用于后台管理的主页面的展示,读取Zrlog的版本信息等。
 */
@Override
public void afterJFinalStart() {
    FreeMarkerRender.getConfiguration().setClassForTemplateLoading(ZrLogConfig.class, com.zrlog.common.Constants.FTL_VIEW_PATH);
    try {
        BlogFrontendFreeMarkerRender.getConfiguration().setDirectoryForTemplateLoading(new File(PathKit.getWebRootPath()));
        BlogFrontendFreeMarkerRender.init(JFinal.me().getServletContext(), Locale.getDefault(), Const.DEFAULT_FREEMARKER_TEMPLATE_UPDATE_DELAY);
    } catch (IOException e) {
        e.printStackTrace();
    }
    super.afterJFinalStart();
    if (isInstalled()) {
        initDatabaseVersion();
    }
    SYSTEM_PROP.setProperty("zrlog.runtime.path", PathKit.getWebRootPath());
    SYSTEM_PROP.setProperty("server.info", JFinal.me().getServletContext().getServerInfo());
    JFinal.me().getServletContext().setAttribute("system", SYSTEM_PROP);
    blogProperties.put("version", BlogBuildInfoUtil.getVersion());
    blogProperties.put("buildId", BlogBuildInfoUtil.getBuildId());
    blogProperties.put("buildTime", new SimpleDateFormat("yyyy-MM-dd").format(BlogBuildInfoUtil.getTime()));
    blogProperties.put("runMode", BlogBuildInfoUtil.getRunMode());
    JFinal.me().getServletContext().setAttribute("zrlog", blogProperties);
    JFinal.me().getServletContext().setAttribute("config", this);
    if (haveSqlUpdated) {
        int updatedVersion = ZrLogUtil.getSqlVersion(getUpgradeSqlBasePath());
        if (updatedVersion > 0) {
            new WebSite().updateByKV(com.zrlog.common.Constants.ZRLOG_SQL_VERSION_KEY, updatedVersion + "");
        }
    }
}
 
Example #29
Source File: TemplateService.java    From zrlog with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #30
Source File: TestConfig.java    From jfinal-ext3 with Apache License 2.0 5 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	TestConfig cfg = new TestConfig();
	cfg.configConstant(JFinal.me().getConstants());
	System.out.println(JFinalExt.DOWNLOAD_PATH);
	System.out.println(JFinalExt.UPLOAD_PATH);
	System.out.println(JFinalExt.DEV_MODE);
}