如果如get方式的传的参数值是中文,进行如下解码不会发生乱码。post方式传的参数进行如下解码也是没问题。
public String getParameter(String name) {
String ss = this.request.getParameter(name);
if (StringUtil.isNullOrEmpty(ss)) {
return "";
}
if (ss != null) {
try
{
byte[] bs = ss.getBytes("ISO-8859-1");
for (int i = 0; i < bs.length; i++) {
byte b = bs[i];
if (b == 63)
break;
if (b <= 0)
{
if (b < 0) {
ss = new String(bs, "UTF-8");
break;
}
}
}
} catch (UnsupportedEncodingException e) { e.printStackTrace(); }
}
return ss;
}