1、使用反斜杠进行转义
<span th:text="${title}" th:style="'font-family:\'MY_FONT_' + ${id} + '\''"></span>
2、使用文本替换语法
Literal substitutions表达式允许出现单引号且不需要转移
<span th:text="${title}" th:style="|font-family:'MY_FONT_${id}'|"></span>
结果
<span style="font-family:'MY_FONT_12345678'">xxx</span>