当前位置: 首页>>代码示例>>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;未经允许,请勿转载。