本文整理汇总了Java中org.springframework.web.servlet.mvc.support.RedirectAttributes.addFlashAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java RedirectAttributes.addFlashAttribute方法的具体用法?Java RedirectAttributes.addFlashAttribute怎么用?Java RedirectAttributes.addFlashAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.servlet.mvc.support.RedirectAttributes
的用法示例。
在下文中一共展示了RedirectAttributes.addFlashAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: closeChallenge
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@RequestMapping("/closeChallenge/{challengeId}")
public RedirectView closeChallenge(@PathVariable Long challengeId,
RedirectAttributes redirectAttributes) {
logger.debug("Closing challenge");
Challenge currentChallenge = challengeService.findOne(challengeId);
if (!challengeService.isParticipating(currentChallenge, userService.getCurrentUser())) {
logger.debug("User trying to close somebody else's challenge. Redirecting to /error.");
redirectAttributes.addFlashAttribute("message", "user not in challenge");
return new RedirectView("/error");
}
challengeService.closeChallenge(currentChallenge);
redirectAttributes.addFlashAttribute("message", "Challenge closed.");
return new RedirectView("/user");
}
示例2: deleteView
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
/**
* POST deletes the selected view.
*/
@RequestMapping(path = "/delete/{id}", method = RequestMethod.POST)
public String deleteView(@PathVariable final Long id, final RedirectAttributes redirectAttributes) {
// Retrieve it
final View view = viewRepository.findOne(id);
if (view == null) {
// Set flash message & redirect
redirectAttributes.addFlashAttribute("FlashMessage", FlashMessage.newWarning("Unable to find view!"));
} else {
// Delete it
viewRepository.delete(id);
redirectAttributes.addFlashAttribute("FlashMessage", FlashMessage.newSuccess("Deleted view!"));
}
// redirect to cluster index
return "redirect:/configuration/view";
}
示例3: 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";
}
示例4: signup
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@RequestMapping(value="/signup/new",method=RequestMethod.POST)
public String signup(@Valid SignupForm signupForm, BindingResult result, RedirectAttributes redirectAttributes) {
if(result.hasErrors()) {
return "signup/form";
}
String email = signupForm.getEmail();
if(calendarService.findUserByEmail(email) != null) {
result.rejectValue("email", "errors.signup.email", "Email address is already in use.");
return "signup/form";
}
CalendarUser user = new CalendarUser();
user.setEmail(email);
user.setFirstName(signupForm.getFirstName());
user.setLastName(signupForm.getLastName());
user.setPassword(signupForm.getPassword());
int id = calendarService.createUser(user);
user.setId(id);
userContext.setCurrentUser(user);
redirectAttributes.addFlashAttribute("message", "You have successfully signed up and logged in.");
return "redirect:/";
}
示例5: resetRequestParams
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
private void resetRequestParams(String clientId, Integer accessTokenValiditySeconds,
Integer refreshTokenValiditySeconds, List<String> grantTypes, List<String> scopes,
boolean autoApproveAll, List<String> autoApproveScopes, List<String> resourceIds,
String redirectUris, RedirectAttributes attributes, Integer intervalInMills,
Integer limits) {
attributes.addFlashAttribute("clientId", clientId);
attributes.addFlashAttribute("accessTokenValiditySeconds", accessTokenValiditySeconds);
attributes.addFlashAttribute("refreshTokenValiditySeconds", refreshTokenValiditySeconds);
attributes.addFlashAttribute("selectedGrantTypes", grantTypes);
attributes.addFlashAttribute("selectedScopes", scopes);
attributes.addFlashAttribute("autoApproveAll", autoApproveAll);
attributes.addFlashAttribute("selectedAutoApproveScopes", autoApproveScopes);
attributes.addFlashAttribute("selectedResourceIds", resourceIds);
attributes.addFlashAttribute("redirectUris", redirectUris);
attributes.addFlashAttribute("intervalInMills", intervalInMills);
attributes.addFlashAttribute("limits", limits);
}
示例6: 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";
}
示例7: doPost
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
handleParameters(request);
redirectAttributes.addFlashAttribute("settings_toast", true);
return "redirect:sonosSettings.view";
}
示例8: removeSession
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@DeleteMapping(value="/user/sessions/{sessionId}")
public String removeSession(@PathVariable String sessionId, RedirectAttributes redirectAttrs) {
SessionInformation sessionInformation = sessionRegistry.getSessionInformation(sessionId);
if(sessionInformation != null) {
sessionInformation.expireNow();
}
redirectAttrs.addFlashAttribute("message", "Session was removed");
return "redirect:/user/sessions/";
}
示例9: signup
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@PostMapping(value="/signup/new")
public String signup(@Valid SignupForm signupForm, BindingResult result, RedirectAttributes redirectAttributes) {
if(result.hasErrors()) {
return "signup/form";
}
String email = signupForm.getEmail();
if(calendarService.findUserByEmail(email) != null) {
result.rejectValue("email", "errors.signup.email", "Email address is already in use.");
return "signup/form";
}
CalendarUser user = new CalendarUser();
user.setEmail(email);
user.setFirstName(signupForm.getFirstName());
user.setLastName(signupForm.getLastName());
user.setPassword(signupForm.getPassword());
logger.info("CalendarUser: {}", user);
int id = calendarService.createUser(user);
user.setId(id);
userContext.setCurrentUser(user);
redirectAttributes.addFlashAttribute("message", "You have successfully signed up and logged in.");
return "redirect:/";
}
示例10: activateAccount
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@RequestMapping(value = "user/activate", method = GET)
public String activateAccount(@RequestParam(value = "key") String key, RedirectAttributes redirectAttrs) {
if (null != userService.activateRegistration(key)) {
redirectAttrs.addFlashAttribute("message", "您的账号激活成功!");
return "redirect:/me";
} else {
redirectAttrs.addFlashAttribute("message", "您的账号激活失败!");
return "redirect:/me";
}
}
示例11: signup
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@RequestMapping(value="/signup/new",method=RequestMethod.POST)
public String signup(@Valid SignupForm signupForm, BindingResult result, RedirectAttributes redirectAttributes) {
if(result.hasErrors()) {
return "signup/form";
}
String email = signupForm.getEmail();
if(calendarService.findUserByEmail(email) != null) {
result.rejectValue("email", "errors.signup.email", "Email address is already in use.");
return "signup/form";
}
CalendarUser user = new CalendarUser();
user.setEmail(email);
user.setFirstName(signupForm.getFirstName());
user.setLastName(signupForm.getLastName());
user.setPassword(signupForm.getPassword());
logger.info("CalendarUser: {}", user);
int id = calendarService.createUser(user);
user.setId(id);
userContext.setCurrentUser(user);
redirectAttributes.addFlashAttribute("message", "You have successfully signed up and logged in.");
return "redirect:/";
}
示例12: stream
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
/**
* Serves standard http requested page with client JS code.
*/
@RequestMapping(path = "/{id}", method = RequestMethod.GET)
public String stream(
@PathVariable final Long id,
final Model model,
final RedirectAttributes redirectAttributes) {
// Retrieve view
final View view = viewRepository.findOne(id);
if (view == null) {
// Set flash message
redirectAttributes.addFlashAttribute("FlashMessage", FlashMessage.newWarning("Unable to find view!"));
// redirect to home
return "redirect:/";
}
// Setup breadcrumbs
new BreadCrumbManager(model)
.addCrumb("Stream", "/stream")
.addCrumb(view.getName());
// Set view attributes
model.addAttribute("view", view);
model.addAttribute("userId", getLoggedInUserId());
return "stream/index";
}
示例13: logining
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
/**
* 用户登录
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/login", method = {RequestMethod.POST})
public ModelAndView logining(String username, String password, RedirectAttributes model, HttpServletRequest request) {
String exceptionClassName = (String) request.getAttribute("shiroLoginFailure");
String error = null;
if (UnknownAccountException.class.getName().equals(exceptionClassName)) {
error = "用户名/密码错误";
} else if (IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {
error = "用户名/密码错误";
} else if (ExcessiveAttemptsException.class.getName().equals(exceptionClassName)) {
error = "输入错误次数太过,请稍后重试";
} else if (LockedAccountException.class.getName().equals(exceptionClassName)) {
error = "账户被锁定,请联系管理员";
} else if (DisabledAccountException.class.getName().equals(exceptionClassName)) {
error = "账户被删除,请联系管理员";
} else if (AccountUnActiveException.class.getName().equals(exceptionClassName)) {
error = "账户未激活,请登录邮箱激活账号!";
} else if (AuthenticationException.class.getName().equals(exceptionClassName)) {
error = "未知错误!";
} else if (exceptionClassName != null) {
error = "错误提示:" + exceptionClassName;
}
if (error != null) {
model.addFlashAttribute("shiroLoginFailure", error);
return new ModelAndView("redirect:/login");
}
return new ModelAndView("redirect:/index");
}
示例14: create
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
@PostMapping(params = "form")
public ModelAndView create(@Valid Item item,BindingResult result,RedirectAttributes redirect) {
if (result.hasErrors()) { return new ModelAndView(ITEM_URI + "form","formErrors",result.getAllErrors()); }
item = this.itemRepository.save(item);
redirect.addFlashAttribute("globalMessage","Item gravado com sucesso");
return new ModelAndView("redirect:/" + ITEM_URI + "{item.id}","item.id",item.getId());
}
示例15: checkout
import org.springframework.web.servlet.mvc.support.RedirectAttributes; //导入方法依赖的package包/类
/**
*
*/
@PostMapping("/cart/pay")
public ModelAndView checkout(ModelAndView modelAndView, HttpSession session, RedirectAttributes redirectAttributes) {
MovieCart movieCart = (MovieCart) session.getAttribute(SESSION_ATTR_MOVIE_CART);
if (movieCart != null) {
log.info("Your request {} will be processed, thank your for shopping", movieCart);
session.removeAttribute(SESSION_ATTR_MOVIE_CART);
}
modelAndView.setViewName("redirect:/");
redirectAttributes.addFlashAttribute("orderStatus", 1);
return modelAndView;
}