Tag Archives: Printer ‘%s’ is low on at least one marker supply.

How to Solve freemaker null Error

Error analysis

Today, I encountered a problem. When I get the parent ID , I found that if it is a parent classification, an error will be reported when I go back to the parent ID

the following styles fail directly.

Solution:

Add a default value of 0. The code is as follows:

var cate_parentId = ${category.parentId ! 0};

When using freemaker template to get values, an error is reported when the attribute is empty

When the expression ${(user. Name)! “} in freemaker is empty, an error is reported directly

FreeMarker is a template engine written in Java language. It generates text output based on the template and uses FreeMarker to judge whether the object is empty.

    general data is judged at the back end, and the front end only displays it regardless of logic. Freemaker displays that an object uses ${name}.
    but if the name is null, freemaker will report an error. If you need to judge whether the object is empty: & lt; #if name?& gt;… & lt;/#if & gt;. You can also set the default value ${name! “”} To avoid the error that the object is empty. If the name is empty, it will be displayed with the default value (the character after “!”). The object user and name are the attributes of user. At this time, both user and name may be empty, which can be written as ${(user. Name)! “”}, indicating that user or name is null, which will be displayed as empty.