Common web forms contain a number of drop-down values--the list of states, the list of countries, and so on. These lists of values need to be available in the model so that the view can display the list. Such common things are typically populated into the model using methods that are marked with @ModelAttribute annotations.
There are two variations possible. In the following example, the method returns the object that needs to be put into the model:
@ModelAttribute public List<State> populateStateList() { return stateService.findStates(); }
The approach in this example is used to add multiple attributes to the model:
@ModelAttribute public void populateStateAndCountryList() { model.addAttribute(stateService.findStates()); ...