package com.kidgrow.common.utils; import cn.hutool.core.util.StrUtil; import lombok.extern.slf4j.Slf4j; import java.net.URLDecoder; import java.net.URLEncoder; /** * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020
* * @Description:
* @Project:
* @CreateDate: Created in 2020/2/11 11:54
* @Author: liuke */ @Slf4j public class StrHelper { public static String getObjectValue(Object obj) { return obj == null ? "" : obj.toString(); } /** * 请使用 URLUtil.encode * @param value * @return */ public static String encode(String value) { try { return URLEncoder.encode(value, "utf-8"); } catch (Exception e) { return ""; } } /** * 请使用 URLUtil.decode * @param value * @return */ public static String decode(String value) { try { return URLDecoder.decode(value, "utf-8"); } catch (Exception e) { return ""; } } public static String getOrDef(String val, String def) { return StrUtil.isEmpty(val) ? def : val; } }