Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何通过th:style-using";使用内联CSS;那个“操作员”;百里香_Html_Css_Thymeleaf - Fatal编程技术网

Html 如何通过th:style-using";使用内联CSS;那个“操作员”;百里香

Html 如何通过th:style-using";使用内联CSS;那个“操作员”;百里香,html,css,thymeleaf,Html,Css,Thymeleaf,如果一个学生通过使用下面的表达式而失败,我尝试将边框颜色设置为红色 <div class="image_wrap" th:style="${student.studentExamStatus}?border-style: solid;border-color: red;:"> 但我有以下例外 请求处理失败;嵌套异常是org.thymeleaf.exceptions.TemplateProcessingException:无法作为表达式解析:“${student.studentE

如果一个学生通过使用下面的表达式而失败,我尝试将边框颜色设置为红色

<div class="image_wrap" th:style="${student.studentExamStatus}?border-style: solid;border-color: red;:">

但我有以下例外 请求处理失败;嵌套异常是
org.thymeleaf.exceptions.TemplateProcessingException:无法作为表达式解析:“${student.studentExamStatus}?边框样式:纯色;边框颜色:红色;:”


${student.studentExamStatus}将返回0或1,无论学生是否通过考试。

正如@Andrew所说,您需要将样式语句嵌套在单引号中。并且必须在括号内包含表达式:

<div class="image_wrap" th:style="${student.studentExamStatus ? 'border-style: solid;border-color: red;' : ''}">

我认为您需要将样式语句嵌套在单引号中。否则,Thymeleaf将尝试将样式中的冒号视为运算符。