V
V
Valera Programmer2015-05-31 13:01:14
Java
Valera Programmer, 2015-05-31 13:01:14

How do you like this way?

Good time of the day!
I am making one framework on Spring MVC, at one time I could not connect a template engine on a java config,
and I had to reinvent my wheel.
here's what I got:

the base template
af43c5417dc54188a73d17f2ef860e8a.png

here I am passing the paths that I store in the Map to the points ${head} ${adminHeader} ${adminContent} ${adminFooter}
something like:

adminTemplate.put("head", "/WEB-INF/ views/admin/options/header/adminHeadConfig.jsp");
adminTemplate.put("adminHeader", "/WEB-INF/views/admin/options/components/admin-header.jsp");
adminTemplate.put("adminFooter", "/WEB-INF/views/admin/options/components/admin-footer.jsp");

and here is the controller part:

0f4db255290b41d8af84980e0343efc5.png
here I am passing model.addAllObjects(renderView.getAdminTemplate()); the entire Map, it passes to the base template the paths that match in the Map and JSP page, i.e.: ${head} ${adminHeader} ${adminFooter}
and in the line model.addObject("adminContent" ,renderView.getAdminTemplate().get(" adminSEO"));
I pass the content itself, the content depends on the page type.

how do you like this decision?
put it into the furnace and use template engines or leave it as it is?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2015-06-02
@noddux

The bike is pretty unreliable. There are also a bunch of templating engines (or tag libraries for JSPs) that support inheritance and create reusable components: JSF, Struts, Tiles , Rapid-Framework, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question