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

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

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

JFinal.getConstants介绍

暂无

代码示例

代码示例来源: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: 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. private void debugPrintParas(Object... objects) {
  2. if (JFinal.me().getConstants().getDevMode()) {
  3. System.out.println("\r\n---------------Paras: " + Arrays.toString(objects) + "----------------");
  4. }
  5. }

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

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

  1. public static void writeString(File file, String string) {
  2. FileOutputStream fos = null;
  3. try {
  4. fos = new FileOutputStream(file, false);
  5. fos.write(string.getBytes(JFinal.me().getConstants().getEncoding()));
  6. } catch (Exception e) {
  7. } finally {
  8. close(null, fos);
  9. }
  10. }

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

  1. public static String getFileFlag(String uri) {
  2. if (JFinal.me().getConstants().getDevMode()) {
  3. return new File(PathKit.getWebRootPath() + uri).lastModified() + "";
  4. }
  5. return cacheFileMap.get(uri);
  6. }
  7. }

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

  1. public static String readString(File file) {
  2. ByteArrayOutputStream baos = null;
  3. FileInputStream fis = null;
  4. try {
  5. fis = new FileInputStream(file);
  6. baos = new ByteArrayOutputStream();
  7. byte[] buffer = new byte[1024];
  8. for (int len = 0; (len = fis.read(buffer)) > 0;) {
  9. baos.write(buffer, 0, len);
  10. }
  11. return new String(baos.toByteArray(), JFinal.me().getConstants().getEncoding());
  12. } catch (Exception e) {
  13. } finally {
  14. close(fis, baos);
  15. }
  16. return null;
  17. }

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

  1. public static String urlRedirect(String redirect) {
  2. try {
  3. redirect = new String(redirect.getBytes(JFinal.me().getConstants().getEncoding()), "ISO8859_1");
  4. } catch (UnsupportedEncodingException e) {
  5. log.error("urlRedirect is error", e);
  6. }
  7. return redirect;
  8. }

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

  1. public static String urlEncode(String string) {
  2. try {
  3. return URLEncoder.encode(string, JFinal.me().getConstants().getEncoding());
  4. } catch (UnsupportedEncodingException e) {
  5. log.error("urlEncode is error", e);
  6. }
  7. return string;
  8. }

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

  1. public static String urlDecode(String string) {
  2. try {
  3. return URLDecoder.decode(string, JFinal.me().getConstants().getEncoding());
  4. } catch (UnsupportedEncodingException e) {
  5. log.error("urlDecode is error", e);
  6. }
  7. return string;
  8. }

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

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

代码示例来源:origin: com.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. private byte[] getRequestBodyBytes(String url) throws IOException {
  2. HttpFileHandle fileHandler = new HttpFileHandle(JFinal.me().getConstants().getBaseUploadPath());
  3. HttpUtil.getInstance().sendGetRequest(url, new HashMap<>(), fileHandler, new HashMap<>());
  4. return IOUtil.getByteByInputStream(new FileInputStream(fileHandler.getT().getPath()));
  5. }

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

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

相关文章