Java Code Examples for cn.hutool.core.util.StrUtil#trim()

The following examples show how to use cn.hutool.core.util.StrUtil#trim() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseForm.java    From datax-web with MIT License 6 votes vote down vote up
/**
 * 构造方法
 */
public BaseForm() {
    try {
        HttpServletRequest request = ServletUtils.getRequest();
        Enumeration<String> params = request.getParameterNames();
        while (params.hasMoreElements()) {
            String name = params.nextElement();
            String value = StrUtil.trim(request.getParameter(name));
            this.set(name, URLDecoder.decode(value, "UTF-8"));
        }
        this.parsePagingQueryParams();
    } catch (Exception e) {
        e.printStackTrace();
        log.error("BaseControlForm initialize parameters setting error:" + e);
    }
}
 
Example 2
Source File: ServletUtils.java    From datax-web with MIT License 5 votes vote down vote up
/**
 * 从请求对象中扩展参数数据,格式:JSON 或  param_ 开头的参数
 *
 * @param request 请求对象
 * @return 返回Map对象
 */
public static Map<String, Object> getExtParams(ServletRequest request) {
    Map<String, Object> paramMap = null;
    String params = StrUtil.trim(request.getParameter(DEFAULT_PARAMS_PARAM));
    if (StrUtil.isNotBlank(params) && StrUtil.startWith(params, "{")) {
        paramMap = (Map) JSONUtil.parseObj(params);
    } else {
        paramMap = getParametersStartingWith(ServletUtils.getRequest(), DEFAULT_PARAM_PREFIX_PARAM);
    }
    return paramMap;
}
 
Example 3
Source File: StringUtil.java    From Jpom with MIT License 5 votes vote down vote up
/**
 * 获取启动参数
 *
 * @param args 所有参数
 * @param name 参数名
 * @return 值
 */
public static String getArgsValue(String[] args, String name) {
    if (args == null) {
        return null;
    }
    for (String item : args) {
        item = StrUtil.trim(item);
        if (item.startsWith("--" + name + "=")) {
            return item.substring(name.length() + 3);
        }
    }
    return null;
}