此方法在单击链接时打开一个页面,该链接中我需要message属性的值,但没有添加servlet和jsp,如何显示它?我的html是空的
@GetMapping("/activate/{code}")
public String activate(ModelMap model, @PathVariable String code) {
boolean isActivated = userService.activateUser(code);
if (isActivated) {
model.addAttribute("message", "User Successfully activated");
System.out.println("Successfully");
} else System.out.println("Activation code not found");
model.addAttribute("message", "Activation code not found");
return "verificationPage";
}
答案 0 :(得分:2)
尝试使用RedirectAttributes
@GetMapping("/activate/{code}")
public String activate(ModelMap model, @PathVariable String code, RedirectAttributes redirAttrs) {
redirAttrs.addFlashAttribute("message", "Here is your message");
}