當前位置: 首頁>>代碼示例>>Java>>正文


Java Model.asMap方法代碼示例

本文整理匯總了Java中org.springframework.ui.Model.asMap方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.asMap方法的具體用法?Java Model.asMap怎麽用?Java Model.asMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.ui.Model的用法示例。


在下文中一共展示了Model.asMap方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLogin

import org.springframework.ui.Model; //導入方法依賴的package包/類
@GetMapping
public String getLogin(Model model, RedirectAttributes redirectAttributes) {

    // Keep flash attributes in the next view
    Map<String, Object> attributesMap = model.asMap();
    for (String modelKey : attributesMap.keySet()) {
        redirectAttributes.addFlashAttribute(modelKey, attributesMap.get(modelKey));
    }


    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    Object userAccountObject = auth.getPrincipal();

    boolean isInstanceOfUserAccount = userAccountObject instanceof UserAccount;
    if (!isInstanceOfUserAccount) {
        log.info("Redirect from / to /login");
        return "redirect:/login";
    }

    UserAccount userAccount = (UserAccount) userAccountObject;

    if (userAccount.hasRole(Role.ADMIN)) {
        return "redirect:/admin/studyplans";
    } else if (userAccount.hasRole(Role.LECTURER)) {
        return "redirect:/lecturer/courses";
    } else {
        return "redirect:/student/courses";
    }
}
 
開發者ID:university-information-system,項目名稱:uis,代碼行數:30,代碼來源:RootController.java

示例2: deleteTokenFrom

import org.springframework.ui.Model; //導入方法依賴的package包/類
/**
 * Delete token from specified model
 *
 * @param model
 */
public void deleteTokenFrom(Model model) {

    if (model.asMap() == null || model.asMap().get(modelTokenName) == null) {
        logger.error("Token not found: " + model);
    } else {
        model.asMap().put(modelTokenName, null);
    }

}
 
開發者ID:remipassmoilesel,項目名稱:simple-hostel-management,代碼行數:15,代碼來源:TokenManager.java

示例3: showLists

import org.springframework.ui.Model; //導入方法依賴的package包/類
/**
 * Send user to a page showing all his lists
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ModelAndView showLists(Principal principal, Model model) {
	LOGGER.debug("home() method of MvcController called for user: {}", principal.getName());

	ModelAndView mav = new ModelAndView("showAllLists", model.asMap());
	List<ShoppingList> shoppingLists = repositoryService.getShoppingLists(principal.getName());
	mav.addObject("shoppingLists", shoppingLists); //current ShoppingLists of the user to display
	if(!model.containsAttribute("newList"))
		mav.addObject("newList", new ShoppingListDTO()); //backing object for name of the new ShoppingList
	mav.addObject("listToDelete", new ShoppingListDTO()); //backing object for ShoppingList to delete
	return mav;
}
 
開發者ID:Azanx,項目名稱:Smart-Shopping,代碼行數:16,代碼來源:MvcController.java

示例4: showRegistrationForm

import org.springframework.ui.Model; //導入方法依賴的package包/類
/**
 * Shows registration form for unlogged users, if user is logged shows message and link to the home page
 * @param model
 */
@RequestMapping(value = "/register", method = RequestMethod.GET)
public ModelAndView showRegistrationForm(Model model) {
	LOGGER.debug("showRegistrationForm() called");
	ModelAndView mav = new ModelAndView("register", model.asMap());
	if(!model.containsAttribute("newUser"))
		mav.addObject("newUser", new AppUserDTO());
	return mav;
}
 
開發者ID:Azanx,項目名稱:Smart-Shopping,代碼行數:13,代碼來源:MvcController.java

示例5: notifyModal

import org.springframework.ui.Model; //導入方法依賴的package包/類
/**
 * Da usare direttamente solo quando si vuole fare un redirect dopo aver mostrato un messaggio.
 * Se chiamato tante volte, i messaggi si sommano e vengono mostrati tutti all'utente.
 * @param title
 * @param message
 * @param severity a string like YadaConstants.VAL_NOTIFICATION_SEVERITY_OK
 * @param redirectSemiurl e.g. "/user/profile"
 * @param model
 * @see YadaConstants
 * @deprecated Use YadaNotify instead
 */
@Deprecated 
public void notifyModal(String title, String message, String severity, String redirectSemiurl, Model model) {
	if (severity==VAL_NOTIFICATION_SEVERITY_ERROR) {
		// Tutte le notifiche di errore vengono loggate a warn (potrebbero non essere degli errori del programma)
		log.warn("notifyModal: {} - {}", title, message);
	}
	// Mette nel model tre array di stringhe che contengono titolo, messaggio e severity.
	if (!model.containsAttribute(KEY_NOTIFICATION_TITLE)) {
		List<String> titles = new ArrayList<String>();
		List<String> bodies = new ArrayList<String>();
		List<String> severities = new ArrayList<String>();
		model.addAttribute(KEY_NOTIFICATION_TITLE, titles);
		model.addAttribute(KEY_NOTIFICATION_BODY, bodies);
		model.addAttribute(KEY_NOTIFICATION_SEVERITY, severities);
	}
	// Aggiunge i nuovi valori
	Map<String, Object> modelMap = model.asMap();
	((List<String>)modelMap.get(KEY_NOTIFICATION_TITLE)).add(title);
	((List<String>)modelMap.get(KEY_NOTIFICATION_BODY)).add(message);
	((List<String>)modelMap.get(KEY_NOTIFICATION_SEVERITY)).add(severity);
	// Il redirect è sempre uno solo: prevale l'ultimo
	if (redirectSemiurl!=null) {
		model.addAttribute(KEY_NOTIFICATION_REDIRECT, redirectSemiurl);
	}
	String newTotalSeverity = calcTotalSeverity(modelMap, severity);
	model.addAttribute(KEY_NOTIFICATION_TOTALSEVERITY, newTotalSeverity);
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:39,代碼來源:YadaWebUtil.java

示例6: callScriptOnModal

import org.springframework.ui.Model; //導入方法依賴的package包/類
/**
 * Add a script id to call when opening the notification modal
 * @param scriptId
 * @param model
 * @deprecated Use YadaNotify instead
 */
@Deprecated 
public void callScriptOnModal(String scriptId, Model model) {
	if (!model.containsAttribute(KEY_NOTIFICATION_CALLSCRIPT)) {
		List<String> scriptIds = new ArrayList<String>();
		model.addAttribute(KEY_NOTIFICATION_CALLSCRIPT, scriptIds);
	}
	Map<String, Object> modelMap = model.asMap();
	((List<String>)modelMap.get(KEY_NOTIFICATION_CALLSCRIPT)).add(scriptId);
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:16,代碼來源:YadaWebUtil.java


注:本文中的org.springframework.ui.Model.asMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。