Flash Attributes
Explore how to enhance user experience by implementing flash attributes in a Spring Boot and Thymeleaf application. Learn to pass success messages via redirect attributes, create a reusable Thymeleaf alert fragment with JavaScript for dismissal, and display dynamic messages after deleting an entity. This lesson helps you build interactive feedback mechanisms following user actions.
The need for flash attributes
The delete works nicely, but the usability could be improved. The modal just closes without any indication that the user was actually removed. It would be a lot better to show a message after the redirect to the list of users. Something like “User Francine Connely was deleted.”
What are flash attributes?
Spring MVC has the concept of flash attributes. These attributes can be added in the controller’s POST and will be made available in the GET method following the ...