thymeleaf 模版引擎
阿新 • • 發佈:2018-12-13
問題 name為null時<p>hello<p>還顯示嗎?
<div th:text="{$name}">
<p>hello</p>
</div>
th:text th:utext 不對tag標籤轉意
${} 使用上下文中的變數 #{} 存放在配置檔案中的變數
<p th:text="#{home.welcome}">Welcome to our grocery store!</p>
基本語法
First, let’s see a quick summary of the Standard Expression features: Simple expressions: Variable Expressions: ${...} Selection Variable Expressions: *{...} Message Expressions: #{...} Link URL Expressions: @{...} Literals Text literals: 'one text', 'Another one!',… Number literals: 0, 34, 3.0, 12.3,… Boolean literals: true, false Null literal: null Literal tokens: one, sometext, main,… Text operations: String concatenation: + Literal substitutions: |The name is ${name}| Arithmetic operations: Binary operators: +, -, *, /, % Minus sign (unary operator): - Boolean operations: Binary operators: and, or Boolean negation (unary operator): !, not Comparisons and equality: Comparators: >, <, >=, <= (gt, lt, ge, le) Equality operators: ==, != (eq, ne) Conditional operators: If-then: (if) ? (then) If-then-else: (if) ? (then) : (else) Default: (value) ?: (defaultvalue)