user1214302
user1214302

Reputation: 23

Providing object to any Tiles layout containing Tile in Spring MVC

I have a tile which lists articles from object provided to it. This tile is part of most pages, but not all of them. Is there any way of automatically providing object only to pages which need it (contain specific tile)? Now i just have @ModelAttribute in every controller which points to page containing tile, but that is not very flexible because if you change layout, you also need to change controller.

Upvotes: 1

Views: 200

Answers (1)

Ralph
Ralph

Reputation: 120831

If you have any rule, that one can decide for the request url if the article list is needed, then you can implement a HandlerInterceptor.

That intercept all requests in the postHandle method , and add the article list, if the "rule" said that it should be added.

Upvotes: 1

Related Questions