java url中文编码

public class Common{
 public static String encode(String s) {
  try {
   return URLEncoder.encode(s,JspRunConfig.CHARSET);
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }
  return s;
 }
 public static String decode(String s) {
  try {
   return URLDecoder.decode(s,JspRunConfig.CHARSET);
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }
  return s;
 }
}
使用时,如果不做任何处理就直接传递,中文也许没有问题(但不保证),但空格肯定会有问题,到接收页面无法识别。
解决办法1:Common.encode(sContent,"utf-8"); 然后再传递。比如url是"accept.jsp?content="+sContent;
读取时,使用
String sc = request.getParameter("content");
sc = new String(sc.getBytes("iso-8859-1"),"utf-8");