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