Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
VRaptor JSP Template plugin
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


VRaptor 3 Simple Template Plugin

This is a plugin to add layout around your views, simple like Ruby on Rails do, using ONLY JSP without freemarker, velocity, etc.

Configuring the plugin in your project

First of all configure the VRaptor classpath package scan adding the simple-template-plugin to your web.xml as follows:


Configuring your Controller

The plugin doesn't change any default behavior of VRaptor. You can add it to a legacy code and start to use templates without break any working view. To configure the controller all you need to do is annotate the controller with @Layout

@Layout @Resource public class PersonController { //your actions here }

Writing your layout:

The plugin you search your layout file: WEB-INF/jsp/layouts/{CONTROLLER_NAME}.jsp. In the examlpe below the plugin would search for the file WEB-INF/jsp/layouts/person.jsp. If the file doesn't exist the plugin will search for a WEB-INF/jsp/layouts/application.jsp. Inside your layout file you don't hava to configure nothing. All you need is add a where you want the local view will be displayed. Example:

Always before the local view Always after the local view

Customizing the layout file name

As you see above, the plugin will search for a file with the name of the controller or the application if the specific file doesn't exist, but if you want, you may change the layout name using the value property in the annotation:
@Layout("custom_layout") @Resource public class PersonController { //your actions here }
Now, the file searched will be WEB-INF/jsp/layouts/custom_layout.jsp

More configuration

Because the plugin doesn't change the the default workingflow of the VRaptor you would have to annotate ALL controller with @Layout. To simplify you configuration you may create a and annotate the package with @Layout and then, every controller in this package will be affected.
@Layout package app.controllers;


If both, package AND class have the annotation, the class you override the configuration.

Full example

You can see a project example here:

Something went wrong with that request. Please try again.