W
W
wolf-98302016-10-16 12:09:54
Java
wolf-9830, 2016-10-16 12:09:54

How to properly avoid duplicate view code?

In spring mvc, I call the view and each time I describe the page again, given that the footer and header of the site are the same, tell me how to make it more convenient, for example, in php it was something like this:
Generic template.php file
--- the header is written
<?= $content ?>
-- the footer is written
How to make similar but only on java springmvc?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Кирилл Романов, 2016-10-16
@Djaler

Например, Thymeleaf умеет в подключение разных файлов в один как фрагментов.

Руслан Лопатин, 2016-10-16
@lorus

Способов много. Если используете JSP, то можно, например, tag files
Тогда ваш код может выглядеть как-то так:

<my:page title="Title">
   Content
</my:page>

Но обычно в JSP используют что-то вроде Tiles, поскольку JSP толком никто не знает.
Да и JSP нынче использовать немодно.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question