1

I am working on a Spring Boot project which basically serving the UI from resources/public. When the request for the main page is arrived, I want to modify the index.html to add some data.

How can I do that?

EDIT: I forgot to mention that, the UI is written with AngularJS,HTML & SCSS if this changes anything. And I don't want to change variables, just want to add some data in <script> tag.

1 Answer 1

2

You can use a template engine such as Thymeleaf, Velocity, Freemarker...

In your Controller fill your model :

model.addAttribute("name", name);

In your Thymeleaf template :

<p th:text="'Hello, ' + ${name} + '!'" />

Here's an example with Thymeleaf : https://spring.io/guides/gs/serving-web-content/

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer, please take a look at my question again for edit part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.