Templates in a Spring MVC web application

前端 未结 4 2358
北海茫月
北海茫月 2021-02-19 21:21

I have a lot of common areas in my web application design, for example footer, header sidebar, blocks...etc and going through all of the application JSP files to change somethin

相关标签:
4条回答
  • 2021-02-19 21:47

    I have used Apache Tiles. It can be very easily integrated with Spring MVC. You can also consider using sitemesh. As you mentioned header template, footer template you can have base template for header, footer, menu and you can integrate them into base template,

    Note : You can only have jsp and not html here.

    Check this link for spring with tiles.

    http://www.springbyexample.org/examples/dynamic-tiles-spring-mvc-module.html

    0 讨论(0)
  • 2021-02-19 21:49

    As for templating you have the following options:

    1. Custom JSP tags. These tags may exist as Java classes or JSP snippets and provide a basic facility to encapsulate and reuse parts of JSP pages (headers, footers, etc.). See more in this manual

    2. Template engines like Tiles or decorators like Sitemesh. They are quite powerfull in building complex page layouts.

    If you're looking for custom UI themes support please take a look at custom themes support in Spring MVC.

    0 讨论(0)
  • 2021-02-19 21:50

    If you want to seperate Header, Footer and some other common stuff from the "real" content, then you can use Apache Tiles.

    It is easy to integrate in spring. So for example Spring Roo use it.

    0 讨论(0)
  • 2021-02-19 21:50

    Ideally yes, You need to create common files instead of redundant code because it might leads to many changes if u want to change a single thing. So try to use below code based on your requirement.

    <%@ include is a static include, <jsp:include is a dynamic include.

    Another solution: As you are using Spring framework try to use spring tiles search in google for more help for example SpringByExample

    0 讨论(0)
提交回复
热议问题