當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。