本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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";
}