FreeMarker 4: FreeMarker basic grammar: branch judgment

Continue to the previous blog:

The ftl file is a script! ! !

table of Contents

One: if branch judgment

(1) Basic example

(2)?? Determine whether the object is empty; true: not empty; false: empty

(3) Use "==" to judge whether the strings are equal in Freemarker

Two: switch branch judgment


Judgment branch

One: if branch judgment

(1) Basic example

(2)?? Determine whether the object is empty; true: not empty; false: empty

Solution: judge when outputting:

(3) Use "==" to judge whether the strings are equal in Freemarker

To judge whether the strings are equal in Java, use the equals() method; while judging whether the strings are equal in Freemarker, use "==":


Two: switch branch judgment

<#switch computer1.state>
	<#case 1>
		状态:正在使用
		<#break>
	<#case 2>
		状态:闲置
		<#break>
	<#case 3>
		状态:已报废
		<#break>
	<#default>
		状态:无效状态
</#switch>


Select if and switch as needed~~~

Guess you like

Origin blog.csdn.net/csucsgoat/article/details/114636433
Recommended