I use Spring MVC. I need to add attribute to request or other object. It should be message that will display on screen. For example, if I use pure Servlets I may just:
request.setAttribute("message", "User deleted");
and than on JSP page
<div id="message">${message}</div>
but when I try to do something like this in method:
@RequestMapping(value = "/delete", method = RequestMethod.GET)
public String deleteUser(@RequestParam("login") String login,
ModelMap map, HttpServletRequest request)
Model object -
model.addAttribute("message", "User deleted");
Map -
map.put("message", "User deleted");
ModelMap -
map.put("message", "User deleted");
HttpServletRequest -
request.setAttribute("message", "User deleted");
nothing displays. But in my browser I see: http:// localhost : 8081 /project/index?message=User+deleted
How to solve this little problem? Thanks for your answers
Updated:
for clear understanding I try to do this:
@RequestMapping(value = "/delete", method = RequestMethod.GET)
public String deleteUser(@RequestParam("login") String login,
Model model) {
dao.delete(login); // there is NO exeptions
map.addAttribute("message", "User " + login + " deleted");
return "redirect:" + "index";
}
in my JSP I also display user login this way:
${user.login}
it takes user from Session and I see it login
PATH_REDIRECT's value?