当前位置: 首页>>代码示例>>Java>>正文


Java ModelMap.clear方法代码示例

本文整理汇总了Java中org.springframework.ui.ModelMap.clear方法的典型用法代码示例。如果您正苦于以下问题:Java ModelMap.clear方法的具体用法?Java ModelMap.clear怎么用?Java ModelMap.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ui.ModelMap的用法示例。


在下文中一共展示了ModelMap.clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setModelMap

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/** 设置响应代码 */
protected ResponseEntity<ModelMap> setModelMap(ModelMap modelMap, HttpCode code, Object data) {
	Map<String, Object> map = InstanceUtil.newLinkedHashMap();
	map.putAll(modelMap);
	modelMap.clear();
	for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
		String key = iterator.next();
		if (!key.startsWith("org.springframework.validation.BindingResult") && !key.equals("void")) {
			modelMap.put(key, map.get(key));
		}
	}
	if (data != null) {
		if (data instanceof Page) {
			Page<?> page = (Page<?>) data;
			modelMap.put("data", page.getRecords());
			modelMap.put("current", page.getCurrent());
			modelMap.put("size", page.getSize());
			modelMap.put("pages", page.getPages());
			modelMap.put("total", page.getTotal());
			modelMap.put("iTotalRecords", page.getTotal());
			modelMap.put("iTotalDisplayRecords", page.getTotal());
		} else if (data instanceof List<?>) {
			modelMap.put("data", data);
			modelMap.put("iTotalRecords", ((List<?>) data).size());
			modelMap.put("iTotalDisplayRecords", ((List<?>) data).size());
		} else {
			modelMap.put("data", data);
		}
	}
	modelMap.put("httpCode", code.value());
	modelMap.put("msg", code.msg());
	modelMap.put("timestamp", System.currentTimeMillis());
	return ResponseEntity.ok(modelMap);
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:35,代码来源:BaseController.java

示例2: setModelMap

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/** 设置响应代码 */
protected ResponseEntity<ModelMap> setModelMap(ModelMap modelMap, HttpCode code, Object data) {
    Map<String, Object> map = InstanceUtil.newLinkedHashMap();
    map.putAll(modelMap);
    modelMap.clear();
    for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
        String key = iterator.next();
        if (!key.startsWith("org.springframework.validation.BindingResult") && !key.equals("void")) {
            modelMap.put(key, map.get(key));
        }
    }
    if (data != null) {
        if (data instanceof Page) {
            Page<?> page = (Page<?>)data;
            modelMap.put("rows", page.getRecords());
            modelMap.put("current", page.getCurrent());
            modelMap.put("size", page.getSize());
            modelMap.put("pages", page.getPages());
            modelMap.put("total", page.getTotal());
        } else if (data instanceof List<?>) {
            modelMap.put("rows", data);
            modelMap.put("total", ((List<?>)data).size());
        } else {
            modelMap.put("data", data);
        }
    }
    modelMap.put("code", code.value().toString());
    modelMap.put("msg", code.msg());
    modelMap.put("timestamp", System.currentTimeMillis());
    logger.info("RESPONSE : " + JSON.toJSONString(modelMap));
    return ResponseEntity.ok(modelMap);
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:33,代码来源:BaseController.java

示例3: addTodo

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value = "/add-todo", method = RequestMethod.POST)
public String addTodo(ModelMap model, @Valid Todo todo, BindingResult result) {
	if (result.hasErrors()) {
		return "todo";
	}
	service.addTodo(retrieveLoggedinUserName(), todo.getDesc(), new Date(),
			false);
	model.clear();
	return "redirect:list-todos";
}
 
开发者ID:ilagaba,项目名称:https-github.com-in28minutes-SpringMvcStepByStep,代码行数:11,代码来源:TodoController.java

示例4: setModelMap

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/** 设置响应代码 */
protected ResponseEntity<ModelMap> setModelMap(ModelMap modelMap, HttpCode code, Object data) {
	Map<String, Object> map = InstanceUtil.newLinkedHashMap();
	map.putAll(modelMap);
	modelMap.clear();
	for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
		String key = iterator.next();
		if (!key.startsWith("org.springframework.validation.BindingResult") && !key.equals("void")) {
			modelMap.put(key, map.get(key));
		}
	}
	if (data != null) {
		if (data instanceof Page) {
			Page<?> page = (Page<?>) data;
			modelMap.put("data", page.getRecords());
			modelMap.put("current", page.getCurrent());
			modelMap.put("size", page.getSize());
			modelMap.put("pages", page.getPages());
			modelMap.put("iTotalRecords", page.getTotal());
			modelMap.put("iTotalDisplayRecords", page.getTotal());
		} else if (data instanceof List<?>) {
			modelMap.put("data", data);
			modelMap.put("iTotalRecords", ((List<?>) data).size());
			modelMap.put("iTotalDisplayRecords", ((List<?>) data).size());
		} else {
			modelMap.put("data", data);
		}
	}
	modelMap.put("httpCode", code.value());
	modelMap.put("msg", code.msg());
	modelMap.put("timestamp", System.currentTimeMillis());
	return ResponseEntity.ok(modelMap);
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:34,代码来源:AbstractController.java

示例5: deleteTodo

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value = "/delete-todo", method = RequestMethod.GET)
public String deleteTodo(ModelMap model, @RequestParam int id) {
	service.deleteTodo(id);
	model.clear();
	return "redirect:list-todos";
}
 
开发者ID:ilagaba,项目名称:https-github.com-in28minutes-SpringMvcStepByStep,代码行数:7,代码来源:TodoController.java


注:本文中的org.springframework.ui.ModelMap.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。