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


Java RedirectAttributes.addAttribute方法代碼示例

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


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

示例1: updateUser

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value = "/users/update/{userId}", method = RequestMethod.POST)
public String updateUser(@Valid UserDTO userDTO, BindingResult result,
                         RedirectAttributes attributes, Model model) {
    if (result.hasErrors()) {
        model.addAttribute("authorities", userService.getRoles());
        return ADMIN_USERFORM_VIEW;
    } else {

        userDTO.setUpdateChildren(true);
        userService.update(userDTO);

        attributes.addAttribute(PARAMETER_USER_ID, userDTO.getUserId());
        webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_USER_UPDATED,
                userDTO.getFirstName() + " " + userDTO.getLastName());

        return "redirect:/admin/users";
    }
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:19,代碼來源:AdminController.java

示例2: deleteCat

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value = "/cats/{id}/delete", method = RequestMethod.POST)
public String deleteCat(@PathVariable("id") long id, final RedirectAttributes redirectAttributes) {

	logger.debug("deleteCat() id: {}", id);

	if (catService.existsById(id)) {
		catService.delete(catService.findById(id).get());
		redirectAttributes.addFlashAttribute("css", "success");
		redirectAttributes.addFlashAttribute("msg", "Cat is deleted!");
	} else {
		redirectAttributes.addAttribute("css", "danger");
		redirectAttributes.addAttribute("msg", "Cat not found.");
	}

	return "redirect:/cats";
}
 
開發者ID:Shonsu,項目名稱:koty,代碼行數:17,代碼來源:KotyController.java

示例3: sendRedirection

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value="/jump_page.html", method=RequestMethod.POST)
public RedirectView sendRedirection(RedirectAttributes atts, @RequestParam("username") String username, 
		@RequestParam("password") String password){
	atts.addFlashAttribute("username", username);
	atts.addFlashAttribute("password", password);
	atts.addAttribute("request", "loginForm");
	return new RedirectView("/redirectviewOld.html",true);
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:9,代碼來源:RedirectPageController.java

示例4: authorize

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
@RequestMapping(value = "/fake/authorize", method = RequestMethod.POST)
public String authorize(
        @RequestParam("state") String state,
        @RequestParam("redirectUri") String redirectUri,
        @RequestParam("username") String username,
        @RequestParam("password") String password,
        RedirectAttributes redirectAttributes) {

  logger.debug("Fake TMC controller received login credentials");

  //TODO: Move the test users to a centralized place from here and DataImporter
  Map<String, String> creds = new HashMap<>();
  creds.put("user", "password");
  creds.put("admin", "password");
  creds.put("impluser", "password");

  if (!creds.containsKey(username) || !creds.get(username).equals(password)) {
    logger.debug("Access denied");
    redirectAttributes.addAttribute("error", "access_denied");
  } else {
    logger.debug("Access granted");
    redirectAttributes.addAttribute("code", username);
  }

  redirectAttributes.addAttribute("state", state);
  String redirectPath = redirectUri.replace("http://localhots:8080", "");

  logger.debug("Redirecting to {}", redirectPath);
  return "redirect:" + redirectPath;
}
 
開發者ID:tdd-pingis,項目名稱:tdd-pingpong,代碼行數:31,代碼來源:FakeTmcController.java

示例5: mailprove

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
/**
 * 驗證郵箱
 * @param checkcode 驗證碼
 * @return
 */
@RequestMapping(value = "/mailprove",method = RequestMethod.GET)
public String mailprove(String checkcode,RedirectAttributes model){
    model.addAttribute("registerType", "email");
    //參數檢測
    if(checkcode==null||"".equals(checkcode)){
        model.addAttribute("code", 500);
        model.addAttribute("msg", "驗證碼不能為空!");
        return "redirect:/system/register/success";
    }
    //獲取校驗參數
    byte[] bytes = SecurityUtil.decryptBASE64(checkcode);
    Map<String,Object> paramMap = ( Map<String,Object>) JavaSerializeUtil.deserialize(bytes);
    String email = (String) paramMap.get("email");
    Date date = (Date) paramMap.get("date");
    model.addAttribute("contact", email);
    if(email==null||date==null||DateUtils.compareDate(new Date(),date, Calendar.HOUR)>48){
        model.addAttribute("code", 500);
        model.addAttribute("msg", "注冊鏈接已過期,請重新注冊!");
        return "redirect:/system/register/success";
    }
    //根據郵箱賬號查找用戶
    List<SysUser> sysUsers = userService.querySysUserByCondition(null, null, email, null, null);
    if(sysUsers==null||sysUsers.size()!=1){
        model.addAttribute("code", 500);
        model.addAttribute("msg", "郵箱激活出現異常,請聯係管理員!");
        return "redirect:/system/register/success";
    }
    //檢測用戶是否已經激活
    SysUser sysUser = sysUsers.get(0);
    if(SysUser.USER_STATUS_ACTIVE.equals(sysUser.getUserStatus())){
        model.addAttribute("code", 500);
        model.addAttribute("msg", "郵箱已經激活,請登錄!");
        return "redirect:/system/register/success";
    }
    //激活用戶
    SysUser registerUser=new SysUser();
    registerUser.setUserId(sysUser.getUserId());
    registerUser.setUserStatus(SysUser.USER_STATUS_ACTIVE);
    registerUser.setEmailActive(SysUser.USER_STATUS_ACTIVE);
    userService.updateById(registerUser);

    model.addAttribute("code", 200);
    model.addAttribute("msg", "郵箱激活成功!");
    return "redirect:/system/register/success";
}
 
開發者ID:babymm,項目名稱:mumu,代碼行數:51,代碼來源:SysRegisterController.java

示例6: modalAutoclose

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
/**
 * Set the automatic closing time for the notification - no close button is shown
 * @param milliseconds
 * @param redirectAttributes
 * @deprecated Use YadaNotify instead
 */
@Deprecated 
public void modalAutoclose(long milliseconds, RedirectAttributes redirectAttributes) {
	redirectAttributes.addAttribute(KEY_NOTIFICATION_AUTOCLOSE, milliseconds);
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:11,代碼來源:YadaWebUtil.java

示例7: modalReloadOnClose

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //導入方法依賴的package包/類
/**
 * Set the page to reload when the modal is closed
 * @param redirectAttributes
 * @deprecated Use YadaNotify instead
 */
@Deprecated 
public void modalReloadOnClose(RedirectAttributes redirectAttributes) {
	redirectAttributes.addAttribute(KEY_NOTIFICATION_RELOADONCLOSE, KEY_NOTIFICATION_RELOADONCLOSE);
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:10,代碼來源:YadaWebUtil.java


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