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

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

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

JFinal.getConstants介绍

暂无

代码示例

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

private static String enCodeUrl(String key) {
    try {
      return URLEncoder.encode(key, JFinal.me().getConstants().getEncoding());
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    return key;
  }
}

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

public static String getFileFlag(String uri) {
    if (JFinal.me().getConstants().getDevMode()) {
      return new File(PathKit.getWebRootPath() + uri).lastModified() + "";
    }
    return cacheFileMap.get(uri);
  }
}

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

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

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

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

代码示例来源: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;
}

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

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

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

public void setCookieDomain(HttpServletRequest request, Cookie cookie) {
    //一些IE遇到localhost的情况下无法正常存储cookie信息
    if (!JFinal.me().getConstants().getDevMode()) {
      cookie.setDomain(getDomain(request));
    }
  }
}

代码示例来源:origin: com.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: 94fzb/zrlog

private byte[] getRequestBodyBytes(String url) throws IOException {
  HttpFileHandle fileHandler = new HttpFileHandle(JFinal.me().getConstants().getBaseUploadPath());
  HttpUtil.getInstance().sendGetRequest(url, new HashMap<>(), fileHandler, new HashMap<>());
  return IOUtil.getByteByInputStream(new FileInputStream(fileHandler.getT().getPath()));
}

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

AdminTokenThreadLocal.setAdminToken(adminTokenVO);
new File(JFinal.me().getConstants().getBaseUploadPath()).mkdirs();
String path = url;
File thumbnailFile;

相关文章