protected Map<String, Object> formatParam(HttpServletRequest request) {
Map<String, Object> param = new HashMap<String, Object>();
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
if (null != request.getParameter(name)
&& !"".equals(request.getParameter(name).trim())) {
try {
param.put(
StringUtils.trim(name),
java.net.URLDecoder.decode(
request.getParameter(name).toString(),
"UTF-8").trim());
} catch (Exception e1) {
param.put(StringUtils.trim(name),(String)request.getParameter(name).trim());
logger.error("UnsupportedEncodingException for search param :"+ name + " 转码异常!");
}
if("order".equalsIgnoreCase(name.trim())){
String orderValue=request.getParameter("order").toString();
if(StringUtils.isNotBlank(orderValue)){
if("asc".equalsIgnoreCase(orderValue)){
param.put("order", "desc");
}else if ("desc".equalsIgnoreCase(orderValue)){
param.put("order", "asc");
}
}
}
}
}
return param;
}
转载于:https://my.oschina.net/marlon520/blog/866433