nan*_*and 3 html css thymeleaf
如果学生不及格,我尝试使用以下表达式将边框颜色设为红色
<div class="image_wrap" th:style="${student.studentExamStatus}?border-style: solid;border-color: red;:">
Run Code Online (Sandbox Code Playgroud)
但是我收到以下异常请求处理失败;嵌套异常为org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "${student.studentExamStatus}?border-style: solid;border-color: red;:"
$ {student.studentExamStatus}将返回基于0或1的学生通过的考试或不通过的考试。
正如@Andrew所说,您需要将样式语句嵌套在单引号中。并且您必须在方括号中包括您的表情:
<div class="image_wrap" th:style="${student.studentExamStatus ? 'border-style: solid;border-color: red;' : ''}">
Run Code Online (Sandbox Code Playgroud)