This example demonstrates how to use Freemarker templating engine to produce web pages via Jersey viewable support.
The mapping of the URI path space is presented in the following table:
URI path | Resource class | HTTP methods |
---|---|---|
/hello | FreemarkerResource | GET |
/autoTemplate | FreemarkerResource | GET |
/helloWithoutSuffix | FreemarkerResource | GET |
See FreemarkerResource for details on how to use jersey-freemaker-webapp module for generating web pages.
If you want to use freemarker in your project, don't forget to set “jersey.config.freemarker.TemplateBasePath” init param, which will be pointing to base directory where your templates are stored (FreemarkerTest class does that).
Run the tests of the example as follows:
mvn clean test
This deploys this example using Grizzly and executes the Jersey Test Framework using the unit test framework.
You can see test classes at src/main/test
subdirectory for detailed information how to consume the service using Client API.
Run the example as follows:
mvn clean package jetty:run
This deploys current example using Jetty. You can access the application at http://localhost:8080/freemarker-webapp/hello