I have seen that I can add errors and render them via <form:errors /> tag and addError() method of BindingResult class, but I wonder if there is something similar to send information messages to the JSP.
I mean, I want to add messages when the operation has been successful. I know I could do it by sending an error, but it would make no sense to me to add errors when there haven’t been any error at all.
Interesting. I found this in an old project of mine.:
(this was a base controller, but could well be an utility method)
and then in a
messages.jspwhich was included in all pages I had:MESSAGES_KEYis a constant of mine with a value “messages” (so that it is later accessible in the forEach loop).The
Messageclass is a simple POJO with those two properties. I used it for info messages as well as for custom non-validation errors.This is a rather custom solution, but perhaps I hadn’t found a built-in solution then. Google a bit more before using such a solution.