Tomcat 上的 Spring:
我想添加图标名称,例如:
<div class="weatherIcon"><i class="wi-night-sleet"></i></div>
来自 http://erikflowers.github.io/weather-icons/ . HTML +CSS
当我像上面的例子一样自己输入时。一切正常。
我正在尝试通过从 Controller 替换字符串来替换文本。 Controller :
model.addAttribute("Icon",g.gson().getCurrently().ChangedIcon());
<div class="weather-Icon"><i class= < th:text="${Icon}"/></i></div>
字符串:
......//some code///
case "clear-night":
return '"' + "wi-night-sleet" + '"';
.....///etc
但我得到的结果是这样的:
<div class="weatherIcon"><i class= <>"wi-night-sleet"</i></i></div>
而且我在网络上没有得到只有图标的字符串
最佳答案
将 HTML 代码更改为:
<div class="weather-Icon"><i th:class="${Icon}"></i></div>
并从返回语句中删除多余的引号
关于java - 如何用引号在 Thymeleaf 问题中添加 <i class ="something"></i>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56088695/