Fork me on GitHub

Rendering objects in HTML views

Of course you want to make your pages dynamic.

It is simple to do so. The Freemarker engine takes any Map and you can access its members inside the view.

public Result userDashboard(
        @PathParam("email") String email,
        @PathParam("id") Integer id,
        Context context) {

    Result result = Results.html();

    result.render("id", Integer.toString(id));
    result.render("email", email);

    return result;


The corresponding view looks like:

        <title>Dashboard for user</title>

        <h1>hi ${email}</h1>

        <p>Your id seems to be: ${id}</p>

Using simple ${email} tags you can access the content of the variables.