I'm using Spring's MVC with JSP views. Every JSP page has similar structure - headers, content, footers, perhaps a sidebar, etc. Looking around for "best practices" people seem to "include" footers and headers, but that means that every JSP page includes these "include" statements, giving a fixed format. To my eye a better solution would involve nested views, where a base template is extended with information appropriate to the page in question. One advantage of this approach is that you can have default values assumed in the base template without repeating them elsewhere. Another advantage is that you can further separate structure and content ("header" and "footer" being structural, and so belonging in the base template) in pages which contain a lot of text (think of help pages - you could put all that in the database, but why bother, especially since with Spring you can resolve to different views via the locale?).
There doesn't seem to be any support for this at the MVC level in Spring, but it could be implemented in JSP using custom tags and, indeed, there's a rather clunky attempt here (that might explain what I want better than this question, although I think you could make it less intrusive).
Anyway, my question is - does this already exist as a (popular/standard) tag library? I'm happy writing custom tags, but my impression of this stuff (generating web sites) is that there's a huge range of solutions already out there, with most work going into choosing the correct tools (eg Spring). Thanks.
Undertow will not support JSP if used as an Embedded Servlet Container. If deploying in a web container, our @SpringBootApplication annotated class should extend SpringBootServletInitializer and provide necessary configuration options. We can't override the default /error page with JSP.
The article discusses the steps involved in developing a Spring web MVC application, explaining the initial project setup for an MVC application in Spring. JSP(Java Server Pages) is used as a view technology.
Thymeleaf is a great templating engine which replaces JSP, and you can easily use it in any Spring MVC or Spring Boot application. Unlike JSP it's a pleasure to use.
I'd recommend SiteMesh. It works well with Spring.
I might not be getting the full picture here but you may also want to take a look at apache tiles
Personally I prefer to avoid the complexity of adding new frameworks, so I just stick with using tag files
If you're not tied to Spring MVC, I would suggest Apache Wicket as it allows for exactly the type of behavior you're describing. It also integrates well with Spring for IoC.
Wicket's markup inheritance
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With