0

My company uses java lite (active web) and freemarker templates for display in some legacy web pages. I wrote an active web AppController which is forwarding to an ftl display file (freemarker template) and I'm able to see the 'hello world' content. However somehow the page is also getting our standard web site header and footer content and I have no idea how to suppress that or where to look. Is there some global configuration for javalite that says to include headers and footers for all pages and can it be supressed?

public class MfaController extends AppController {
    @GET
    public void registration()  {
        //does nothing
    }
}

registration.ftl:

<html>
<body>hello world</body>
</html>
4

1 回答 1

0

JavaLite is not using configuration files. Instead it uses conventions. What you observe is a default behavior. The default layout located in

src/main/webapp/WEB-INF/views/layouts/default_layout.ftl

is applied to all web pages, unless you tell the framework you do not need it.

If you do not want a layout, you can turn it off by overriding a getLayout() method:

public class MfaController extends AppController {

    public void registration()  {
        //does nothing
    }
    public String getLayout(){
        return null;
    }
}

A alternative solution will look like this:

public class MfaController extends AppController {
    public void registration()  {
         render().noLayout();
    }
}

Also, the @GET annotation is redundant, all actions are GET by default if public.

Here is the docs: https://javalite.io/views#default-layout

于 2020-07-18T01:59:07.453 回答