我正在嘗試設定RedirectAttributes,但這樣做時沒有任何反應。這是我的控制器:
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@GetMapping("/run-1")
public String getTests(RedirectAttributes redirectAttributes) {
logger.info("Info Log in Main controller class");
logger.info(workingDir);
redirectAttributes.addFlashAttribute("uploadStatus", "redirectWithRedirectView");
redirectAttributes.addAttribute("uploadStatus", "redirectWithRedirectView");
return "redirect:uploadStatus";
}
這是一個 SpringBoot 專案,因為它是 Spring MVC 上的 Umbrella,所以我認為我可以使用RedirectAttributes. 那么發生了什么?當我到達這個終點時,我回傳:redirect:uploadStatus
uj5u.com熱心網友回復:
@RequestMapping(value = "/session", method = RequestMethod.POST)
public String joinSession(RedirectAttributes redirectAttributes){
/* --- */
redirectAttributes.addFlashAttribute("error", "!!!Wrong Password!!!");
return "redirect:/dashboard";
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/342761.html
上一篇:Java:ObjectMapper在請求/回應后更改Pojo的值/結構
下一篇:如何解決bean創建程序中的意外例外;嵌套例外是java.lang.IllegalStateException:MethodhastoomanyBodyparameters
