根据用户信誉显示图像 - Spring MVC - Thymeleaf

时间:2018-05-12 14:21:41

标签: spring spring-mvc thymeleaf

我想根据用户信誉显示图片。我事先测试了图像,所以我知道URL是正确的。但是我的switch case语法有问题:

<th:block th:switch="${reputation}">
  <div th:case="${reputation} &lt; 0">
       <img  th:src="@{/css/img/troll.png}"/>
  </div>
  <div th:case="0">
       <img  th:src="@{/css/img/smeagol.jpg}"/>
  </div>
  <div th:case="${reputation} &gt; 0 && ${reputation} &lt; 5">
       <img  th:src="@{/css/img/samwise.png}"/>
   </div>
   <div th:case="${reputation} &ge; 5 && ${reputation} &le; 15">
       <img  th:src="@{/css/img/frodo.png}"/>
   </div>
   <div th:case="${reputation} &gt; 15">
       <img  th:src="@{/css/img/gandalf.jpg}"/>
   </div>
</th:block>

这给了我以下错误:

org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 61; The entity name must immediately follow the '&' in the entity reference.

它可能会给我这个错误,因为我试图在这种情况下使用两个范围?

我已经浏览过互联网,但我无法找到这样一个交换机实现的例子。

0 个答案:

没有答案