我正在修复用于呈现PDF文件的HTML模板。问题是我正在使用的新代码适用于一个模板,但在另一个模板中引发CConvertException。控制台除了以下错误外没有给我任何提示:

Oops: CConvertExceptionAn unexpected error occured caused by exception CConvertException:ERROR: An unhandled exception occured: ERROR: An Exception occured while reconstructing the pdf document: ERROR: An unhandled exception occured: null

新代码涉及使用新的Java扩展,它将String转换为另一个,如下所示:

#{if person?.name != null} ${person?.name.getInitials().toString()} #{/if}

由于某种原因,此确切的代码破坏了一个模板,但在另一个模板上工作正常。我究竟做错了什么?

最佳答案

不确定这是否是原因,但是您在这里使用安全导航操作符?.有点奇怪。并且getInitials()不会自动返回String吗?

为什么不直接写(没有周围的if语句):

// Returns the name or an empty String if name or person is null.
${person?.name?.getInitials() ?: ""}

关于java - Play 中的CConvertException!构架,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8529692/

10-13 03:32