首先,了解下freemarker导出word的流程:
参考https://www.cnblogs.com/llfy/p/9303208.html
异常一:
freemarker.core.ParseException: Encountered "<" at line 3, column 3011 in niuwode.ftl.
Was expecting one of:
<STRING_LITERAL> ...
<RAW_STRING> ...
"false" ...
"true" ...
<INTEGER> ...
<DECIMAL> ...
"." ...
"+" ...
"-" ...
"!" ...
"[" ...
"(" ...
"{" ...
<ID> ...
原因是.xml转成.ftl时,${name}中间多了很多word的样式,
例如:${</w:t></w:r><w:r><w:rPr><w:lang w:val="zh-CN"/></w:rPr><w:t>name</w:t></w:r><w:r><w:rPr><w:rFonts w:hint="eastAsia"/><w:lang w:val="zh-CN"/></w:rPr><w:t>}
删除样式后,变为${name}即可。
异常二:
The following has evaluated to null or missing:
这是因为模板中用到的参数,在给模板赋值时找不到,为null