Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; public class Main { public static String getRequestParamValue(Object obj, String charset) { if (obj == null) { return ""; } String value; if (obj instanceof List) { StringBuilder sb = new StringBuilder(); if (obj != null) { for (Object o : (List<?>) obj) { if (o != null) { sb.append(o.toString()); sb.append(','); } } } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } value = sb.toString(); } else { value = obj.toString(); } try { return URLEncoder.encode(value, charset); } catch (UnsupportedEncodingException e) { return value; } } }