I started to learn Spring and came onto @ModelAttribute annotation, which i can find real use for. Can someone give me a real example of it? Because as i understand (i'm just beginner so might be wrong), methods that are annoteded with @ModelAttribute add return value/object into Model before every request. I saw examples like :
@ModelAttribute
List<Person> addList()
{
return personRepository.findAll();
}
however usually Controllers are responsible for many other actions like adding or removing existing element (where we don't need that list). So once again can can someone give me a real example? Or maybe i misunderstand some things about that annotation.