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