本文整理汇总了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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
示例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";
}
}
}
示例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";
}
}
示例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";
}
}