当前位置: 首页>>代码示例>>Java>>正文


Java Model.containsAttribute方法代码示例

本文整理汇总了Java中org.springframework.ui.Model.containsAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Model.containsAttribute方法的具体用法?Java Model.containsAttribute怎么用?Java Model.containsAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ui.Model的用法示例。


在下文中一共展示了Model.containsAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: settings

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/{ssoId}/settings", method = RequestMethod.GET)
public String settings(@PathVariable("ssoId") String ssoId, Model model, RedirectAttributes attr){
    if(!ssoId.equals(userService.getPrincipal())){
        attr.addFlashAttribute("error","You are not allowed to visit this page.");
        return "redirect:/error";
    }
    User user = userService.getUserBySsoId(ssoId, false);
    if(user == null){
        attr.addFlashAttribute("error","User does not exist");
        return "redirect:/error";
    }
    if(!model.containsAttribute("userSettingsDTO")) {
        UserSettingsDTO userSettingsDTO = new UserSettingsDTO(user.getSsoId(), user.getEmail(), user.getName(), user.getUserDetail().getUserBio());
        model.addAttribute("userSettingsDTO", userSettingsDTO);
    }

    model.addAttribute("userName", userService.getPrincipal());
    model.addAttribute("categories", categoryService.getCategories());
    return "settings";
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:21,代码来源:UserController.java

示例2: settings

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/{ssoId}/settings", method = RequestMethod.GET)
public String settings(@PathVariable("ssoId") String ssoId, Model model, RedirectAttributes attr){
    if(!ssoId.equals(userService.getPrincipal())){
        attr.addFlashAttribute("error","You are not allowed to visit this page.");
        return "redirect:/oups";
    }
    User user = userService.getUserBySsoId(ssoId, false);
    if(user == null){
        attr.addFlashAttribute("error","User does not exist");
        return "redirect:/oups";
    }
    if(!model.containsAttribute("userSettingsDTO")) {
        UserSettingsDTO userSettingsDTO = new UserSettingsDTO(user.getSsoId(), user.getEmail(), user.getName(), user.getUserDetail().getUserBio());
        model.addAttribute("userSettingsDTO", userSettingsDTO);
    }

    model.addAttribute("userName", userService.getPrincipal());
    model.addAttribute("categories", categoryService.getCategories());
    return "settings";
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:21,代码来源:UserController.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: displayForm

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
protected String displayForm(HttpServletRequest request, Model model) throws Exception {
    UserSettingsCommand command;
    if(!model.containsAttribute("command")) {
         command = new UserSettingsCommand();

        User user = getUser(request);
        if (user != null) {
            command.setUser(user);
            command.setEmail(user.getEmail());
            UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
            command.setTranscodeSchemeName(userSettings.getTranscodeScheme().name());
            command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(user)));
        } else {
            command.setNewUser(true);
            command.setStreamRole(true);
            command.setSettingsRole(true);
        }

    } else {
        command = (UserSettingsCommand) model.asMap().get("command");
    }
    command.setAdmin(User.USERNAME_ADMIN.equals(command.getUsername()));
    command.setUsers(securityService.getAllUsers());
    command.setTranscodingSupported(transcodingService.isDownsamplingSupported(null));
    command.setTranscodeDirectory(transcodingService.getTranscodeDirectory().getPath());
    command.setTranscodeSchemes(TranscodeScheme.values());
    command.setLdapEnabled(settingsService.isLdapEnabled());
    command.setAllMusicFolders(settingsService.getAllMusicFolders());
    model.addAttribute("command", command);
    return "userSettings";
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:33,代码来源:UserSettingsController.java

示例6: index

import org.springframework.ui.Model; //导入方法依赖的package包/类
@GetMapping("/")
public String index(Model model) {
  if (model.containsAttribute("name")) {
    String name = (String) model.asMap().get("name");
    Map<String, String> greeting = helloworldService.greeting(name);
    model.addAttribute("greeting", greeting);
  }

  model.addAttribute("messages", guestbookService.all());

  return "index";
}
 
开发者ID:saturnism,项目名称:istio-by-example-java,代码行数:13,代码来源:HelloworldUiController.java

示例7: index

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping
public String index(HttpServletRequest httpServletRequest, Model uiModel, @RequestParam(value = "type", required = false) String type) {
	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	String eppn = auth.getName();
	
   	if(uiModel.containsAttribute("type")){
       	Map<String, ?> flashInputMap = RequestContextUtils.getInputFlashMap(httpServletRequest);
       	if(flashInputMap.containsKey("type")){
       		type = (String) flashInputMap.get("type");
       	}	
   	}
   	if(type==null){
   		type="";
   	}
	uiModel.addAttribute("selectedType", type);
	ObjectMapper mapper = new ObjectMapper();
	String jsonStats = "";
	String jsonStatsRm = "";
	List<String> prefsStats = new ArrayList<>();
	List<String> prefsStatsRm = new ArrayList<>();
	try {
		if(preferencesService.getPrefs(eppn, KEY)!=null){
			prefsStats = Arrays.asList(preferencesService.getPrefs(eppn, KEY).getValue().split("\\s*,\\s*"));
		}
		jsonStats = mapper.writeValueAsString(prefsStats);
		if(preferencesService.getPrefs(eppn, KEYRM)!=null){
			prefsStatsRm = Arrays.asList(preferencesService.getPrefs(eppn, KEYRM).getValue().split("\\s*,\\s*"));
		}
		jsonStatsRm = mapper.writeValueAsString(prefsStatsRm);
		
	} catch (Exception e) {
		e.printStackTrace();
	}
	uiModel.addAttribute("prefs",jsonStats);
	uiModel.addAttribute("prefsRm",jsonStatsRm);
	uiModel.addAttribute("prefsRmList",prefsStatsRm);
	return "manager/stats";
}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:39,代码来源:StatsController.java

示例8: loginPage

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String loginPage(Model model, HttpServletRequest request){
    if(userService.getPrincipal() != null){ return "redirect:/"; }
    if(!model.containsAttribute("userDTO")){
        model.addAttribute("userDTO", new UserDTO());
    }

    return "login";
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:10,代码来源:LoginController.java

示例9: isYadaNotifySaved

import org.springframework.ui.Model; //导入方法依赖的package包/类
/**
 * Check if the YadaNotify.yadaSave() has been called in this request
 * @param model can be null
 * @param redirectAttributes can be null
 * @return
 */
@Deprecated
public static boolean isYadaNotifySaved(Model model, RedirectAttributes redirectAttributes) {
	boolean result = false;
	if (model!=null) {
		result = model.containsAttribute(KEY_NOTIFICATION_TITLE);
	}
	if (redirectAttributes!=null) {
		result |= redirectAttributes.getFlashAttributes().containsKey(KEY_NOTIFICATION_TITLE);
	}
	return result;
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:18,代码来源:YadaNotify.java

示例10: admin

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value= {"","/"} , method = RequestMethod.GET)
public String admin(Model model){
    model.addAttribute("userName", userService.getPrincipal());
    model.addAttribute("categories", categoryService.getCategories());
    if(!model.containsAttribute("userDTO")){
        model.addAttribute("userDTO", new UserDTO());
    }
    if(!model.containsAttribute("categoryDTO")){
        model.addAttribute("categoryDTO", new CategoryDTO());
    }
    model.addAttribute("fileUpload", new FileUpload());
    model.addAttribute("accountStates", getAccountStates());
    return "admin";
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:15,代码来源:AdminController.java

示例11: createArticleGET

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String createArticleGET(Model model){
    if(!model.containsAttribute("articleDTO")){
        model.addAttribute("articleDTO", new ArticleDTO());
    }
    model.addAttribute("categories", categoryService.getCategories());
    model.addAttribute("userName", userService.getPrincipal());
    return "article_add";
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:10,代码来源:ArticleController.java

示例12: error

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value = "/oups")
public String error(Model model){
    if(!model.containsAttribute("error")){
        model.addAttribute("error", "You do not have the permission to access this page.");
    }
    if(userService.getPrincipal() != null){
        model.addAttribute("categories", categoryService.getCategories());
        model.addAttribute("userName", userService.getPrincipal());
    }
    return "error";
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:12,代码来源:MainController.java

示例13: admin

import org.springframework.ui.Model; //导入方法依赖的package包/类
@RequestMapping(value= {"","/"} , method = RequestMethod.GET)
public String admin(Model model){
    model.addAttribute("userName", userService.getPrincipal());
    model.addAttribute("categories", categoryService.getCategories());
    if(!model.containsAttribute("userDTO")){
        model.addAttribute("userDTO", new UserDTO());
    }
    if(!model.containsAttribute("categoryDTO")){
        model.addAttribute("categoryDTO", new CategoryDTO());
    }
    model.addAttribute("fileUpload", new FileUpload());
    model.addAttribute("accountStates", State.getAccountStates());
    return "admin";
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:15,代码来源:AdminController.java

示例14: 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

示例15: 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.containsAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。