本文整理汇总了Java中org.springframework.ui.ModelMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java ModelMap.get方法的具体用法?Java ModelMap.get怎么用?Java ModelMap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ui.ModelMap
的用法示例。
在下文中一共展示了ModelMap.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveArgument
import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@Override
public Object resolveArgument(
MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
throws Exception {
ModelMap model = mavContainer.getModel();
if (model.size() > 0) {
int lastIndex = model.size()-1;
String lastKey = new ArrayList<String>(model.keySet()).get(lastIndex);
if (lastKey.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
return model.get(lastKey);
}
}
throw new IllegalStateException(
"An Errors/BindingResult argument is expected to be declared immediately after the model attribute, " +
"the @RequestBody or the @RequestPart arguments to which they apply: " + parameter.getMethod());
}
示例2: updateBindingResult
import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/**
* Add {@link BindingResult} attributes to the model for attributes that require it.
*/
private void updateBindingResult(NativeWebRequest request, ModelMap model) throws Exception {
List<String> keyNames = new ArrayList<String>(model.keySet());
for (String name : keyNames) {
Object value = model.get(name);
if (isBindingCandidate(name, value)) {
String bindingResultKey = BindingResult.MODEL_KEY_PREFIX + name;
if (!model.containsAttribute(bindingResultKey)) {
WebDataBinder dataBinder = binderFactory.createBinder(request, value, name);
model.put(bindingResultKey, dataBinder.getBindingResult());
}
}
}
}
示例3: afficher
import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value="/afficherModificationToDoList", method = RequestMethod.GET)
public String afficher(final ModelMap pModel) {
if (pModel.get("modification") == null) {
final List<ToDoList> lToDoLists = service.RechercherToDoList();
final ModificationForm lModificationForm = new ModificationForm();
final List<ModificationToDoList> lListe = new LinkedList<ModificationToDoList>();
for (final ToDoList lToDoList : lToDoLists) {
final ModificationToDoList lModificationToDoList = new ModificationToDoList();
lModificationToDoList.setId(lToDoList.getId());
lModificationToDoList.setLibelle(lToDoList.getLibelle());
lListe.add(lModificationToDoList);
}
lModificationForm.setToDoList(lListe);
pModel.addAttribute("modification", lModificationForm);
}
return "modification";
}
示例4: afficher
import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value="/afficherCreationToDoList", method = RequestMethod.GET)
public String afficher(final ModelMap pModel) {
//Création d'un objet ToDoList puis Lecture de la table
final List<ToDoList> lToDoLists = service.RechercherToDoList();
pModel.addAttribute("creertodolist", lToDoLists);
if (pModel.get("creation") == null) {
pModel.addAttribute("creation", new CreationForm());
}
return "creation";
}