private String urlEncode(Object obj, String charset) {
try {
return URLEncoder.encode(obj.toString(), (charset != null) ? charset : GrailsWebUtil.DEFAULT_ENCODING);
}
catch (UnsupportedEncodingException ex) {
throw new ControllerExecutionException(
"Error creating URL, cannot URLEncode to the client's character encoding: " + ex.getMessage(), ex);
}
}