/
cldev
/
teststatic
Обзор
Документация
Войти
/
cldev
/
teststatic
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main/java/ru/example/DynamicContent.java
28 строк
900 B
Alexander Barantsev
Initial commit
07 авг 2026, 02:22
07 авг 2026, 02:22
eaac964
Код
Авторство
О чём код?
package ru.example; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.stereotype.Component; import org.springframework.util.StreamUtils; import java.io.IOException; import java.nio.charset.StandardCharsets; @Component public class DynamicContent { private static final String FILE_NAME = "dynamic.html"; private static final String FIELD_NAME = "\\$\\{test\\}"; private final String obj; DynamicContent(@Value("${test}") String fieldValue) throws IOException { Resource resource = new ClassPathResource(FILE_NAME); String content = StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8); obj = content.replaceAll(FIELD_NAME, fieldValue); } public String get() { return obj; } }