freemarker 不支持 boolean 类型 Templates do break when an attrib

                If in a template <td>${attribute.value}</td> is used, and value is boolean, the following exception is thrown:
freemarker.core.NonStringException: Error on line 19, column 3 in description.ftl
Expecting a string, date or number here, Expression a.value is instead a freemarker.ext.beans.BooleanModel
- quote: "..Unlike numbers, booleans has no commonly accepted format, not even a
common format within the same page. Like when you show on a HTML page.."
"...The common way of formatting a boolean is like ${washable?string("yes", "no")},
${caching?string("Enabled", "Disabled")}, ${heating?string("on", "off")}, etc..."
- By the other hand, the Features used in the unit test for FeatureTemplate contained no boolean properties. Adding a boolean property to the test data still didn't make the error to show up, as the template used uses <td>${attribute.value.toString()}</td>. Changing the template to use <td>${attribute.value}</td> exposes the error.
           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自blog.csdn.net/gruhgd/article/details/87610414
今日推荐