Spring Based JSP Templates

I am using Spring MVC with JSP views. Each JSP page has a similar structure - headers, content, footers, possibly a sidebar, etc. Looking back at “best practices,” people seem to “include” footers and headers, but that means that every JSP page has these “included” statements, giving a fixed format. In my opinion, the best solution would include nested views, where the basic template is expanded with information relevant to the page in question. One of the advantages of this approach is that you can use the default values ​​in the base template without repeating them elsewhere. Another advantage is that you can further separate the structure and content (the "header" and the "footer", which is structural, and therefore belongs to the base template) on pages that contain a lot of text (think about the help pages - you can put it all in the database, but why bother, especially since with Spring you can resolve different views through the locale?).

There seems to be no support for this at the MVC level in Spring, but it can be implemented in JSP using custom tags and there really is a rather clumsy attempt here (this may explain what I want better than this question, although I think that you could make it less intrusive).

Anyway, my question is: does this already exist as a (popular / standard) tag library? I am happy to write custom tags, but my impression of this material (website creation) is that there is already a huge selection of solutions, with most of the work going on choosing the right tools (for example, Spring). Thanks.

+4
source share
4 answers

I would recommend SiteMesh . It works well with Spring.

+6
source

I may not be able to get the full picture, but you can also take a look at apache tiles

Personally, I prefer to avoid the difficulty of adding new frameworks, so I just stick to tag files

+3
source

If you are not attached to Spring MVC, I would suggest Apache Wicket, as it allows you to accurately describe the type of behavior that you are describing. It also integrates well with Spring for IoC.

Inheritance of a marking of a gate

+2
source

I would recommend Apache Tiles

I did this with SiteMesh and Tiles. But I think Tiles is better for this job than SiteMesh. - In MHO, the goal of SiteMesh is to manipulate existing web pages more.

+1
source

All Articles