package com.sunxung.factoring.component.util;

import java.util.Map;

public class StitchingUrlUtil {

    /**
     * 拼接请求地址与参数
     * 
     * @param url
     * @param params
     * @return
     */
    public static String getUrl(String url, Map<String, String> params) {
        StringBuilder sb = new StringBuilder(url);
        sb.append('?');
        for (Map.Entry<String, String> entry : params.entrySet()) {
            sb.append(entry.getKey()).append('=').append(entry.getValue()).append('&');
        }
        sb.deleteCharAt(sb.length() - 1);// 删除最后一个"&"
        return sb.toString();
    }
}
