This is due to a change in Thymeleaf Spring - you can get your sample working by downgrading the Thymeleaf version like:
In its implementation, Thymeleaf is trying to add new entries to the existing model map - but since its introduction in Spring 5.0, DefaultRenderingResponseBuilder enforces an immutable map and passes that to the View.render method, which contract does not expect an unmodifiable model.
Arjen Poutsma, rstoyanchev, Juergen Hoeller - any opinion on that? Should we improve the existing View.render doc to expect an immutable map? Or should we remove that constraint from our implementation?
View.render method which contract does not expect an unmodifiable model.
The documentation of that method says nothing about mutability, so passing a modifiable map is just as unexpected as passing a modifiable one. At most, the behaviour is undefined; not unexpected.
Personally, I think it's rather odd that a View implementation assumes that the passed map is modifiable, especially in the asynchronous world were immutability is desired. So I think that this is a bug in Thymeleaf: it should make a defensive copy of the data if it wants to modify it. Doing that is a good idea anyway, for other reasons (concurrent modifications).