Today, when getting freemarker + springmvc + JDBC, I added several fields with a boolean type of data. The result shows an error.
Expecting a string, date or number here, expression X is instead a freemarker. template. templateboole
Is it because freemarker does not support Boolean when using tags. It only supports string, date, or number. I am here. I thought it was me all day.CodeI wrote an error and checked it for half a day.
I would like to summarize the Usage Details of freemarker here.
1. freemarker throws an exception for null results and needs to be handled by itself. For example:
! Output Space
! 'The default while empty' specifies the default value when it is null.
2. freemarker throws an exception to the boolean result and must handle it by yourself. For example:
Cfg. setbooleanformat ("True, false"); try it on my side. It has no effect. You still need to process the output of Boolean.
<# If bean. bolfield> true <# else> false </# If> use if else to judge and output custom values.
$ {Bean. bolfield? String ("yes", "no")} escape