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


Java RedirectAttributes类代码示例

本文整理汇总了Java中org.springframework.web.servlet.mvc.support.RedirectAttributes的典型用法代码示例。如果您正苦于以下问题:Java RedirectAttributes类的具体用法?Java RedirectAttributes怎么用?Java RedirectAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createEvent

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping(value = "/new", method = RequestMethod.POST)
public String createEvent(@Valid CreateEventForm createEventForm, BindingResult result,
        RedirectAttributes redirectAttributes) {
    if (result.hasErrors()) {
        return "events/create";
    }
    CalendarUser attendee = calendarService.findUserByEmail(createEventForm.getAttendeeEmail());
    if (attendee == null) {
        result.rejectValue("attendeeEmail", "attendeeEmail.missing",
                "Could not find a user for the provided Attendee Email");
    }
    if (result.hasErrors()) {
        return "events/create";
    }
    Event event = new Event();
    event.setAttendee(attendee);
    event.setDescription(createEventForm.getDescription());
    event.setOwner(userContext.getCurrentUser());
    event.setSummary(createEventForm.getSummary());
    event.setWhen(createEventForm.getWhen());
    calendarService.createEvent(event);
    redirectAttributes.addFlashAttribute("message", "Successfully added the new event");
    return "redirect:/events/my";
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:25,代码来源:EventsController.java

示例2: createEvent

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@PostMapping(value = "/new")
public String createEvent(@Valid CreateEventForm createEventForm, BindingResult result,
        RedirectAttributes redirectAttributes) {
    if (result.hasErrors()) {
        return "events/create";
    }
    CalendarUser attendee = calendarService.findUserByEmail(createEventForm.getAttendeeEmail());
    if (attendee == null) {
        result.rejectValue("attendeeEmail", "attendeeEmail.missing",
                "Could not find a user for the provided Attendee Email");
    }
    if (result.hasErrors()) {
        return "events/create";
    }
    Event event = new Event();
    event.setAttendee(attendee);
    event.setDescription(createEventForm.getDescription());
    event.setOwner(userContext.getCurrentUser());
    event.setSummary(createEventForm.getSummary());
    event.setWhen(createEventForm.getWhen());
    calendarService.createEvent(event);
    redirectAttributes.addFlashAttribute("message", "Successfully added the new event");
    return "redirect:/events/my";
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:25,代码来源:EventsController.java

示例3: save

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping("business-info-save")
public String save(@ModelAttribute BusinessInfo businessInfo,
        @RequestParam Map<String, Object> parameterMap,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    BusinessInfo dest = null;

    Long id = businessInfo.getId();

    if (id != null) {
        dest = businessInfoManager.get(id);
        beanMapper.copy(businessInfo, dest);
    } else {
        dest = businessInfo;
        dest.setTenantId(tenantId);
    }

    businessInfoManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/business/business-info-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:BusinessInfoController.java

示例4: addList

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
/**
 * adds new shopping list for the current user
 * 
 * @param newList
 *            ShoppingListDTO with basic information about new list (must
 *            include list name)
 */
@RequestMapping(value = "/list", method = RequestMethod.POST)
public String addList(Principal principal, @Valid @ModelAttribute("newList") ShoppingListDTO newList, BindingResult binding, RedirectAttributes attr, HttpSession session) {
	LOGGER.debug("addList() method of MvcController called for user: {}", principal.getName());
	if(!binding.hasErrors()) 
		repositoryService.addShoppingListToUserByName(principal.getName(), newList.getListName());
	else {
		attr.addFlashAttribute("org.springframework.validation.BindingResult.newList", binding);
		attr.addFlashAttribute("newList", newList);
		for(FieldError ferr:binding.getFieldErrors()) {
			LOGGER.info("addList(): field error: " + ferr.getDefaultMessage());
		}
	}
	
	return "redirect:/list";
}
 
开发者ID:Azanx,项目名称:Smart-Shopping,代码行数:23,代码来源:MvcController.java

示例5: createEvent

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@PostMapping(value = "/new")
public String createEvent(@Valid CreateEventForm createEventForm, BindingResult result,
        RedirectAttributes redirectAttributes) {
    if (result.hasErrors()) {
        return "events/create";
    }
    CalendarUser attendee = calendarService.findUserByEmail(createEventForm.getAttendeeEmail());
    if (attendee == null) {
        result.rejectValue("attendeeEmail", "attendeeEmail.missing",
                "Could not find a user for the provided Attendee Email");
    }
    if (result.hasErrors()) {
        return "events/create";
    }
    Event event = new Event();
    event.setAttendee(attendee);
    event.setDescription(createEventForm.getDescription());
    event.setOwner(userContext.getCurrentUser());
    event.setSummary(createEventForm.getSummary());
    event.setWhen(createEventForm.getWhen());
    calendarService.createEvent(event);
    redirectAttributes.addFlashAttribute("message",
            "Successfully added the new event");
    return "redirect:/events/my";
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:26,代码来源:EventsController.java

示例6: doSubmitAction

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command, BindingResult bindingResult, RedirectAttributes redirectAttributes) throws Exception {

    if(!bindingResult.hasErrors()) {
        if (command.isDeleteUser()) {
            deleteUser(command);
        } else if (command.isNewUser()) {
            createUser(command);
        } else {
            updateUser(command);
        }
        redirectAttributes.addFlashAttribute("settings_reload", true);
        redirectAttributes.addFlashAttribute("settings_toast", true);
    } else {
        redirectAttributes.addFlashAttribute("command", command);
        redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.command", bindingResult);
        redirectAttributes.addFlashAttribute("userIndex", getUserIndex(command));
    }

    return "redirect:userSettings.view";
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:22,代码来源:UserSettingsController.java

示例7: save

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping("job-grade-save")
public String save(@ModelAttribute JobGrade jobGrade,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    JobGrade dest = null;
    Long id = jobGrade.getId();

    if (id != null) {
        dest = jobGradeManager.get(id);
        beanMapper.copy(jobGrade, dest);
    } else {
        dest = jobGrade;
        dest.setTenantId(tenantId);
    }

    jobGradeManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/org/job-grade-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:23,代码来源:JobGradeController.java

示例8: save

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping("sendmail-history-save")
public String save(@ModelAttribute SendmailHistory sendmailHistory,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    Long id = sendmailHistory.getId();
    SendmailHistory dest = null;

    if (id != null) {
        dest = sendmailHistoryManager.get(id);
        beanMapper.copy(sendmailHistory, dest);
    } else {
        dest = sendmailHistory;
        dest.setTenantId(tenantId);
    }

    sendmailHistoryManager.save(dest);
    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/sendmail/sendmail-history-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:22,代码来源:SendmailHistoryController.java

示例9: save

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping("perm-type-save")
public String save(@ModelAttribute PermType permType,
        RedirectAttributes redirectAttributes) {
    // copy
    PermType dest = null;
    Long id = permType.getId();

    if (id != null) {
        dest = permTypeManager.get(id);
        beanMapper.copy(permType, dest);
    } else {
        dest = permType;
    }

    if (id == null) {
        dest.setTenantId(tenantHolder.getTenantId());
    }

    // save
    permTypeManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/auth/perm-type-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:27,代码来源:PermTypeController.java

示例10: save

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping("leave-info-save")
public String save(@ModelAttribute LeaveInfo leaveInfo,
        @RequestParam Map<String, Object> parameterMap,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    LeaveInfo dest = null;

    Long id = leaveInfo.getId();

    if (id != null) {
        dest = leaveInfoManager.get(id);
        beanMapper.copy(leaveInfo, dest);
    } else {
        dest = leaveInfo;
        dest.setTenantId(tenantId);
    }

    leaveInfoManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/leave/leave-info-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:LeaveInfoController.java

示例11: save

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping("audit-base-save")
public String save(@ModelAttribute AuditBase auditBase,
        @RequestParam Map<String, Object> parameterMap,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    AuditBase dest = null;

    Long id = auditBase.getId();

    if (id != null) {
        dest = auditBaseManager.get(id);
        beanMapper.copy(auditBase, dest);
    } else {
        dest = auditBase;
        dest.setTenantId(tenantId);
    }

    auditBaseManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/audit/audit-base-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:AuditBaseController.java

示例12: save

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping("party-entity-save")
public String save(@ModelAttribute PartyEntity partyEntity,
        @RequestParam("partyTypeId") Long partyTypeId,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    PartyEntity dest = null;
    Long id = partyEntity.getId();

    if (id != null) {
        dest = partyEntityManager.get(id);
        beanMapper.copy(partyEntity, dest);
    } else {
        dest = partyEntity;
        dest.setTenantId(tenantId);
    }

    dest.setPartyType(partyTypeManager.get(partyTypeId));
    partyEntityManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/party/party-entity-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:PartyEntityController.java

示例13: updateRole

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping(value = "/roles/update/{Id}", method = RequestMethod.POST)
public String updateRole(@Valid @ModelAttribute(value = "authority") RoleDTO roleDTO, BindingResult result,
                         RedirectAttributes attributes, Model model) {
    if (result.hasErrors()) {
        webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_ROLE_ERROR);
        return "redirect:/admin/roles";
    } else {
        Authority authority = userService.getAuthorityById(roleDTO.getId());
        if (authority.isLocked()) {
            webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_ROLE_IS_LOCKED, roleDTO.getAuthority().toUpperCase());
            return "redirect:/admin/roles";
        } else {
            userService.updateAuthority(roleDTO);
            webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_ROLE_UPDATED, roleDTO.getAuthority());
            return "redirect:/admin/roles";
        }
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:19,代码来源:AdminController.java

示例14: deleteRole

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
@RequestMapping(value = "/roles/update/{Id}", params = {"deleteRole"}, method = RequestMethod.POST)
public String deleteRole(@Valid @ModelAttribute(value = "authority") RoleDTO roleDTO, BindingResult result,
                         RedirectAttributes attributes, Model model) {
    if (result.hasErrors()) {
        webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_ROLE_ERROR);
        return "redirect:/admin/roles";
    } else {
        Authority authority = userService.getAuthorityById(roleDTO.getId());

        if (authority.isLocked()) {
            webUI.addFeedbackMessage(attributes,
                    FEEDBACK_MESSAGE_KEY_ROLE_IS_LOCKED, roleDTO.getAuthority());
        } else {
            Collection<User> users = userService.getUsersByAuthorityId(roleDTO.getId());
            userService.deleteAuthority(authority, users);
            webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_KEY_ROLE_DELETED,
                    roleDTO.getAuthority(), users.size());
        }

        return "redirect:/admin/roles";
    }
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:23,代码来源:AdminController.java

示例15: changePasswordSave

import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入依赖的package包/类
/**
 * 修改密码.
 */
@RequestMapping("my-change-password-save")
public String changePasswordSave(
        @RequestParam("oldPassword") String oldPassword,
        @RequestParam("newPassword") String newPassword,
        @RequestParam("confirmPassword") String confirmPassword,
        RedirectAttributes redirectAttributes) {
    Long accountId = Long.parseLong(currentUserHolder.getUserId());
    ChangePasswordResult changePasswordResult = changePasswordService
            .changePassword(accountId, oldPassword, newPassword,
                    confirmPassword);

    if (changePasswordResult.isSuccess()) {
        messageHelper.addFlashMessage(redirectAttributes,
                changePasswordResult.getCode(),
                changePasswordResult.getMessage());

        return "redirect:/user/my-change-password-input.do";
    } else {
        messageHelper.addFlashMessage(redirectAttributes,
                changePasswordResult.getCode(),
                changePasswordResult.getMessage());

        return "redirect:/user/my-change-password-input.do";
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:29,代码来源:MyController.java


注:本文中的org.springframework.web.servlet.mvc.support.RedirectAttributes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。