我需要在 html 页面中使用一些自定义 css,其中 css 样式是从数据库中检索的。当页面调用控制器时,会将 css 样式渲染为 html。我只想显示颜色代码而不是整个范围标签。
这是我需要的结果:
color: #159426;
Run Code Online (Sandbox Code Playgroud)
这是我得到的意想不到的结果:
color: <span>#159426</span>;
Run Code Online (Sandbox Code Playgroud)
这是我的目录结构。
color: #159426;
Run Code Online (Sandbox Code Playgroud)
这是init.html
<script th:inline="javascript" th:fragment="init">
h1, h2, h3, h4, h5, h6, .site-title {
font-family: 'Open Sans', sans-serif;
}
body.site {
border-top: 3px solid <span th:text="${params.templateColor}"/>;
background-color: <span th:text="${params.templateBackgroundColor}"/>;
}
a {
color: <span th:text="${params.templateColor}"/>;
}
</script>
Run Code Online (Sandbox Code Playgroud)
这是我的结果
color: <span>#159426</span>;
Run Code Online (Sandbox Code Playgroud)
thymeleaf ×1