码迷,mamicode.com
首页 > 其他好文 > 详细

请求参数

时间:2020-06-17 23:11:28      阅读:59      评论:0      收藏:0      [点我收藏+]

标签:ram   uid   prope   ext   xtend   servlet   bst   substr   extend   

public class PackData extends HashMap implements Map{

private static final long serialVersionUID = 1L;

Map map = null;
HttpServletRequest request;
public PackData(HttpServletRequest request){
	this.request = request;
	Map properties = request.getParameterMap();
	Map returnMap = new HashMap();
	Iterator entries = properties.entrySet().iterator();
	Entry entry;
	String name = "";
	String value = "";
	while (entries.hasNext()) {
		entry = (Entry) entries.next();
		name = (String) entry.getKey();
		Object valueObj = entry.getValue();
		if(null == valueObj){
			value = "";
		}else if(valueObj instanceof String[]){
			String[] values = (String[])valueObj;
			for(int i=0;i<values.length;i++){
				value = values[i] + ",";
			}
			value = value.substring(0, value.length()-1);
		}else{
			value = valueObj.toString();
		}
		returnMap.put(name, value);
	}
	if(returnMap.containsKey("page")&&returnMap.containsKey("rows")){
		Integer page = Integer.parseInt(returnMap.get("page").toString());
		Integer rows = Integer.parseInt(returnMap.get("rows").toString());
		Integer start = (page==0?0:page-1)*rows;
		Integer end = rows;
		returnMap.put("start", start);
		returnMap.put("end", end);
	}
	map = returnMap;
}

public PackData() {
	map = new HashMap();
}

public PackData(Map map) {
	this.map = map;
}

请求参数

标签:ram   uid   prope   ext   xtend   servlet   bst   substr   extend   

原文地址:https://www.cnblogs.com/cabinet/p/13155024.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!