本文整理匯總了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";
}