com.jfinal.core.JFinal类的使用及代码示例

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

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

JFinal介绍

[英]JFinal
[中]JFinal

代码示例

代码示例来源:origin: JpressProjects/jpress

  1. public String getUrl() {
  2. return JFinal.me().getContextPath() + url;
  3. }

代码示例来源: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: JpressProjects/jpress

  1. /**
  2. * 构建 action 的权限,每个Controller的方法对应一个action
  3. *
  4. * @return
  5. */
  6. private static List<Permission> buildActionPermissions() {
  7. List<Permission> permissions = new ArrayList<>();
  8. List<String> allActionKeys = JFinal.me().getAllActionKeys();
  9. String[] urlPara = new String[1];
  10. for (String actionKey : allActionKeys) {
  11. // 只处理后台的权限 和 API的权限
  12. if (actionKey.startsWith("/admin") || actionKey.startsWith("/api")) {
  13. Action action = JFinal.me().getAction(actionKey, urlPara);
  14. if (action == null || excludedMethodName.contains(action.getMethodName())) {
  15. continue;
  16. }
  17. AdminPermission permissionAnnotation = action.getMethod().getAnnotation(AdminPermission.class);
  18. String text = permissionAnnotation == null ? null : permissionAnnotation.value();
  19. String controller = action.getControllerClass().getName();
  20. Permission permission = new Permission();
  21. permission.setActionKey(actionKey);
  22. permission.setNode(controller);
  23. permission.setText(text);
  24. permission.setType(Permission.TYPE_ACTION);
  25. permissions.add(permission);
  26. }
  27. }
  28. return permissions;
  29. }

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

  1. /**
  2. * 将 String 数据转换为指定的类型
  3. * @param type 需要转换成为的数据类型
  4. * @param s 被转换的 String 类型数据,注意: s 参数不接受 null 值,否则会抛出异常
  5. * @return 转换成功的数据
  6. */
  7. public final Object convert(Class<?> type, String s) throws ParseException {
  8. // mysql type: varchar, char, enum, set, text, tinytext, mediumtext, longtext
  9. if (type == String.class) {
  10. return ("".equals(s) ? null : s); // 用户在表单域中没有输入内容时将提交过来 "", 因为没有输入,所以要转成 null.
  11. }
  12. s = s.trim();
  13. if ("".equals(s)) { // 前面的 String跳过以后,所有的空字符串全都转成 null, 这是合理的
  14. return null;
  15. }
  16. // 以上两种情况无需转换,直接返回, 注意, 本方法不接受null为 s 参数(经测试永远不可能传来null, 因为无输入传来的也是"")
  17. //String.class提前处理
  18. // --------
  19. IConverter<?> converter = converterMap.get(type);
  20. if (converter != null) {
  21. return converter.convert(s);
  22. }
  23. if (JFinal.me().getConstants().getDevMode()) {
  24. throw new RuntimeException("Please add code in " + TypeConverter.class + ". The type can't be converted: " + type.getName());
  25. } else {
  26. throw new RuntimeException(type.getName() + " can not be converted, please use other type of attributes in your model!");
  27. }
  28. }
  29. }

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

  1. AdminTokenThreadLocal.setAdminToken(adminTokenVO);
  2. new File(JFinal.me().getConstants().getBaseUploadPath()).mkdirs();
  3. String path = url;
  4. File thumbnailFile;
  5. thumbnailFile = new File(PathKit.getWebRootPath() + path);
  6. } else {
  7. bytes = IOUtil.getByteByInputStream(new FileInputStream(PathKit.getWebRootPath() + url.replace(JFinal.me().getContextPath(), "")));
  8. path = url.substring(0, url.indexOf('.')) + "_thumbnail" + url.substring(path.indexOf('.'));
  9. thumbnailFile = new File(PathKit.getWebRootPath() + path);
  10. return url;
  11. return new UploadService().getCloudUrl(JFinal.me().getContextPath(), path, thumbnailFile.getPath(), null).getUrl() + "?h=" + height + "&w=" + width;

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

  1. return Freemarkers.renderStrTemplate("<!DOCTYPE html><html><head><title> Application 500 Eroor </title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><style type=\"text/css\">html, body {margin: 0;padding: 0;font-family : Helvetica, Arial, Sans;background: #EEEEEE;}.block {padding: 20px;border-bottom : 1px solid #aaa;}#header h1 {font-weight : normal;font-size: 28px;margin: 0;}#more {color: #666;font-size : 80%;border: none;}#header {background : #fcd2da;}#header p {color : #333;}#source {background : #f6f6f6;}#source h2 {font-weight : normal;font-size: 18px;margin: 0 0 10px 0;}#source .lineNumber {float: left;display: block;width: 40px;text-align: right;margin-right : 10px;font-size: 14px;font-family: monospace;background: #333;color: #fff;}#source .line {clear: both;color: #333;margin-bottom : 1px;}#source pre {font-size: 14px;margin: 0;overflow-x : hidden;}#source .error {color : #c00 !important;}#source .error .lineNumber {background : #c00;}#source a {text-decoration : none;}#source a:hover * {cursor : pointer !important;}#source a:hover pre {background : #FAFFCF !important;}#source em {font-style: normal;text-decoration : underline;font-weight: bold;}#source strong {font-style: normal;font-weight : bold;}</style><body><div id=\"header\" class=\"block\"><h1>Execution exception</h1><p> ${title!} </p></div><div id=\"source\" class=\"block\"><h2>Exception information in detail </h2><#list errors as er><div class=\"line <#if er?starts_with(\"\tat app.\")>error</#if>\"><span class=\"lineNumber\">${er_index + 1}:</span><pre>${er}</pre></div></#list></div></body></html>", pdata);
  2. case SC_NOT_FOUND:
  3. final List<String> allActionKeys = JFinal.me().getAllActionKeys();
  4. pdata.put("routes", allActionKeys);
  5. return Freemarkers.renderStrTemplate("<!DOCTYPE html><html><head><title>Not found</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><style type=\"text/css\">html, body {margin: 0;padding: 0;font-family: Helvetica, Arial, Sans;background: #EEEEEE;}.block {padding: 20px;border-bottom: 1px solid #aaa;}#header h1 {font-weight: normal;font-size: 28px;margin: 0;}#more {color: #666;font-size: 80%;border: none;}#header {background: #FFFFCC;}#header p {color: #333;}#routes {background: #f6f6f6;}#routes h2 {font-weight: normal;font-size: 18px;margin: 0 0 10px 0;}#routes ol {}#routes li {font-size: 14px;font-family: monospace;color: #333;}</style><body><div id=\"header\" class=\"block\"><h1>${requestURI!} Not found</h1></div><div id=\"routes\" class=\"block\"><h2>These routes have been tried, in this order :</h2><ol><#list routes as r><li> ${r} </li></#list></ol></div></body></html>", pdata);

代码示例来源:origin: yangfuhai/jboot

  1. @Override
  2. public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
  3. if (!webConfig.isActionCacheEnable()) {
  4. next.handle(target, request, response, isHandled);
  5. return;
  6. }
  7. Action action = JFinal.me().getAction(target, urlPara);
  8. if (action == null) {
  9. next.handle(target, request, response, isHandled);
  10. return;
  11. }
  12. ActionCacheClear actionClear = action.getMethod().getAnnotation(ActionCacheClear.class);
  13. if (actionClear != null) {
  14. clearActionCache(action, actionClear);
  15. next.handle(target, request, response, isHandled);
  16. return;
  17. }
  18. EnableActionCache actionCache = getActionCache(action);
  19. if (actionCache == null) {
  20. next.handle(target, request, response, isHandled);
  21. return;
  22. }
  23. try {
  24. exec(target, request, response, isHandled, action, actionCache);
  25. } finally {
  26. ActionCacheContext.release();
  27. }
  28. }

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

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

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

  1. public static void start(Class<Goja> configClass) throws Exception {
  2. if (configStarted) {
  3. return;
  4. }
  5. ClassFinder.findWithTest();
  6. Reflect.on(Goja.class).call("initWithTest");
  7. JFinal me = JFinal.me();
  8. configInstance = configClass.newInstance();
  9. initConfig(me, servletContext, configInstance);
  10. handler = Reflect.on(me).get("handler");
  11. configStarted = true;
  12. configInstance.afterJFinalStart();
  13. }

代码示例来源:origin: yangfuhai/jboot

  1. private void debugPrintParas(Object... objects) {
  2. if (JFinal.me().getConstants().getDevMode()) {
  3. System.out.println("\r\n---------------Paras: " + Arrays.toString(objects) + "----------------");
  4. }
  5. }

代码示例来源:origin: yangfuhai/jboot

  1. String callbackControllerKey = controllerKey + "/wechatCallback";
  2. if (!JFinal.me().getAllActionKeys().contains(callbackControllerKey)) {
  3. callbackControllerKey = controllerKey.substring(0, controllerKey.lastIndexOf("/")) + "/wechatCallback";

代码示例来源: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: jfinal/jfinal

  1. static String getContxtPath() {
  2. String cp = JFinal.me().getContextPath();
  3. return ("".equals(cp) || "/".equals(cp)) ? null : cp;
  4. }

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

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

代码示例来源:origin: yangfuhai/jboot

  1. private void debugPrintParas(Object... objects) {
  2. if (JFinal.me().getConstants().getDevMode()) {
  3. System.out.println("\r\n---------------Paras: " + Arrays.toString(objects) + "----------------");
  4. }
  5. }

代码示例来源:origin: JpressProjects/jpress

  1. private static List<MenuItem> buildAdminMenuItems() {
  2. List<MenuItem> adminMenuItems = new ArrayList<>();
  3. List<String> allActionKeys = JFinal.me().getAllActionKeys();
  4. String[] urlPara = new String[1];
  5. for (String actionKey : allActionKeys) {
  6. // 只处理后台的权限 和 API的权限
  7. if (actionKey.startsWith("/admin")) {
  8. Action action = JFinal.me().getAction(actionKey, urlPara);
  9. if (action == null || excludedMethodName.contains(action.getMethodName())) {
  10. continue;
  11. }
  12. AdminMenu adminMenu = action.getMethod().getAnnotation(AdminMenu.class);
  13. if (adminMenu == null) {
  14. continue;
  15. }
  16. MenuItem menu = new MenuItem();
  17. menu.setText(adminMenu.text());
  18. menu.setIcon(adminMenu.icon());
  19. menu.setGroupId(adminMenu.groupId());
  20. menu.setUrl(actionKey);
  21. menu.setOrder(adminMenu.order());
  22. adminMenuItems.add(menu);
  23. }
  24. }
  25. return adminMenuItems;
  26. }

代码示例来源: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: JpressProjects/jpress

  1. public String getDetailUrl() {
  2. return JFinal.me().getContextPath() + "/admin/user/detail/" + getId();
  3. }

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

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

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

  1. private static String enCodeUrl(String key) {
  2. try {
  3. return URLEncoder.encode(key, JFinal.me().getConstants().getEncoding());
  4. } catch (UnsupportedEncodingException e) {
  5. e.printStackTrace();
  6. }
  7. return key;
  8. }
  9. }

相关文章