I have a controller that works, but I do not understand why it works. Here it is:
@Controller
@RequestMapping("/someUrl")
public class MyController {
@Autowired
private SomeService someService;
@RequestMapping(method = RequestMethod.GET)
public String page() throws ApplicationException {
return "page";
}
@ModelAttribute("modelAttribute")
public PageModel loadPageModel() throws ApplicationException {
return someService.createPageModel();
}
}
Visiting "/someUrl" will get me to the view of the name "page", as it is expected. What is puzzling, is that despite the model attribute "modelAttribute", or an object of type "PageModel" is not referenced anywhere near the method page, the modelAttribute is still visible for the view. I am happy that this works, but I do not understand why. Any thoughts?