View engine
Spring MVC provides View and ViewResolver to find view and render view. MVC provides ViewEngine to do the same job.
View Engine
By default, ozark support tow built-in view engines to render JSP and Facelets, respectively.
In the org.glassfish.ozark.ext (check org.glassfish.ozark.ext) package, ozark provides several ViewEngine implementations for the popular template.
Thymeleaf
Freemarker
Velocity
Handlebars
Mustache
Asciidoc
Stringtemplate
Jade
JSR223(Script engine)
Facelets
Originally, Facelets is part of JSF specification, now it can be worked as a standard template engine in MVC.
Activate Facelets in web.xml.
We do not need face-config.xml file to activate JSF here.
Convert all jsp files in the mvc sample to facelets template. Facelets supports Composite View pattern, we can define a template for all views.
The template includes header and footer fragments directly, it also define a content placeholder, in the extended views the content will be inserted in the content definition.
If you are familiar with JSF before, it is easy to understand the codes.
Check out the codes and explore them yourself.
Do not forget to change the view postfix to .xhtml in the
TaskController. eg. the view inallTasksmethod.
Source Codes
Clone the codes from my GitHub account.
Open the mvc-facelets project in NetBeans IDE.
Run it on Glassfish.
After it is deployed and running on Glassfish application server, navigate http://localhost:8080/ee8-mvc/mvc/tasks in browser.
Last updated
Was this helpful?