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

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

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

JFinal.me介绍

暂无

代码示例

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

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

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

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

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

@Override
public String getAvatar() {
  String avatar = super.getAvatar();
  if (avatar != null && avatar.toLowerCase().startsWith("http")) {
    return avatar;
  }
  return JFinal.me().getContextPath() +
      (StrUtils.isNotBlank(avatar) ? avatar : DEFAULT_AVATAR);
}

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

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

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

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

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

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

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

@Override
protected String getUrl(int pageNumber) {
  HttpServletRequest request = JbootRequestContext.getRequest();
  String url = request.getRequestURI();
  String contextPath = JFinal.me().getContextPath();
  if (pageNumber == 1 && firstGotoIndex) {
    return contextPath + "/";
  }
  // 如果当前页面是首页的话
  // 需要改变url的值,因为 上一页或下一页是通过当前的url解析出来的
  if (url.equals(contextPath + "/")) {
    url = contextPath + "/article/category/index"
        + JPressOptions.getAppUrlSuffix();
  }
  return Kits.doReplacePageNumber(url, pageNumber);
}

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

public String getUrl() {
  switch (getType()) {
    case TYPE_CATEGORY:
      return JFinal.me().getContextPath() + "/article/category/" + getSlug() + JPressOptions.getAppUrlSuffix();
    case TYPE_TAG:
      return JFinal.me().getContextPath() + "/article/tag/" + getSlug() + JPressOptions.getAppUrlSuffix();
  }
  return "";
}

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

public String getUrl() {
  if (StrUtils.isBlank(getSlug())) {
    return JFinal.me().getContextPath() + "/" + getId() + JPressOptions.getAppUrlSuffix();
  } else {
    return JFinal.me().getContextPath() + "/" + getSlug() + JPressOptions.getAppUrlSuffix();
  }
}

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

/**
 * 构建 action 的权限,每个Controller的方法对应一个action
 *
 * @return
 */
private static List<Permission> buildActionPermissions() {
  List<Permission> permissions = new ArrayList<>();
  List<String> allActionKeys = JFinal.me().getAllActionKeys();
  String[] urlPara = new String[1];
  for (String actionKey : allActionKeys) {
    // 只处理后台的权限 和 API的权限
    if (actionKey.startsWith("/admin") || actionKey.startsWith("/api")) {
      Action action = JFinal.me().getAction(actionKey, urlPara);
      if (action == null || excludedMethodName.contains(action.getMethodName())) {
        continue;
      }
      AdminPermission permissionAnnotation = action.getMethod().getAnnotation(AdminPermission.class);
      String text = permissionAnnotation == null ? null : permissionAnnotation.value();
      String controller = action.getControllerClass().getName();
      Permission permission = new Permission();
      permission.setActionKey(actionKey);
      permission.setNode(controller);
      permission.setText(text);
      permission.setType(Permission.TYPE_ACTION);
      permissions.add(permission);
    }
  }
  return permissions;
}

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

public String getUrl() {
  String link = getLinkTo();
  if (StrUtils.isNotBlank(link)) {
    return link;
  }
  if (StrUtils.isBlank(getSlug())) {
    return JFinal.me().getContextPath() + "/article/" + getId() + JPressOptions.getAppUrlSuffix();
  } else {
    return JFinal.me().getContextPath() + "/article/" + getSlug() + JPressOptions.getAppUrlSuffix();
  }
}

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

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 adminMenu = action.getMethod().getAnnotation(UCenterMenu.class);
      if (adminMenu == null) {
        continue;
      }
      MenuItem menu = new MenuItem();
      menu.setText(adminMenu.text());
      menu.setIcon(adminMenu.icon());
      menu.setGroupId(adminMenu.groupId());
      menu.setUrl(actionKey);
      menu.setOrder(adminMenu.order());
      adminMenuItems.add(menu);
    }
  }
  return adminMenuItems;
}

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

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) {
    // 只处理后台的权限 和 API的权限
    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;
      }
      MenuItem menu = new MenuItem();
      menu.setText(adminMenu.text());
      menu.setIcon(adminMenu.icon());
      menu.setGroupId(adminMenu.groupId());
      menu.setUrl(actionKey);
      menu.setOrder(adminMenu.order());
      adminMenuItems.add(menu);
    }
  }
  return adminMenuItems;
}

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

public void index() {
  String gotoUrl = getPara("goto");
  String uid = EncryptCookieUtils.get(this, JPressConsts.COOKIE_UID);
  //说明当前用户已经登录
  if (StrUtils.isNotBlank(uid)) {
    redirect(StrUtils.urlDecode(gotoUrl));
    return;
  }
  String appId = JPressOptions.get(JPressConsts.OPTION_WECHAT_APPID);
  if (StrUtils.isBlank(appId)) {
    renderText("管理员的微信APPID配置错误,请联系管理在后台 -> 微信 -> 基础设置 配置正确的APPID。");
    return;
  }
  String domain = JPressOptions.get(JPressConsts.OPTION_WEB_DOMAIN);
  if (StrUtils.isBlank(domain)) {
    domain = getRequest().getScheme() + "://" + getRequest().getServerName();
  }
  if (StrUtils.isNotBlank(JFinal.me().getContextPath())) {
    domain = domain + JFinal.me().getContextPath();
  }
  //这个url是微信执行完毕之后跳转回来的url
  //也是下方的这个 action
  String redirecturi = domain + "/wechat/authorization/back?goto=" + gotoUrl;
  String wechatUrl = AUTHORIZE_URL.replace("{appid}", appId).replace("{redirecturi}", redirecturi);
  redirect(wechatUrl);
}

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

map.put("fileName", attachment.getTitle());
  map.put("uploaded", 1);
  map.put("url", JFinal.me().getContextPath() + attachment.getPath());
  renderJson(map);
} else {

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

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

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

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

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

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) {
  } finally {
    close(null, fos);
  }
}

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

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;
}

相关文章