freemarker报错之六
1、错误描述
五月 28, 2014 10:32:40 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template processing error: "Expression student.course is undefined on line 16, column 25 in course.ftl." Expression student.course is undefined on line 16, column 25 in course.ftl. The problematic instruction: ---------- ==> ${student.course.courseName!} [on line 16, column 23 in course.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression student.course is undefined on line 16, column 25 in course.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125) at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135) at freemarker.core.Dot._getAsTemplateModel(Dot.java:78) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.DefaultToExpression._getAsTemplateModel(DefaultToExpression.java:100) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:259) at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:142) at com.you.test.freemarker.FreemarkerTest.testCourse(FreemarkerTest.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>学生信息</title> </head> <body> 姓名:张三丰 性别:男 年龄:16 生日:1970-01-01 地址:湖北省武汉市武昌洪山区 QQ:78,451,214 课程: 课程名: Expression student.course is undefined on line 16, column 25 in course.ftl. The problematic instruction: ---------- ==> ${student.course.courseName!} [on line 16, column 23 in course.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression student.course is undefined on line 16, column 25 in course.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125) at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135) at freemarker.core.Dot._getAsTemplateModel(Dot.java:78) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.DefaultToExpression._getAsTemplateModel(DefaultToExpression.java:100) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:259) at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:142) at com.you.test.freemarker.FreemarkerTest.testCourse(FreemarkerTest.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Expression student.course is undefined on line 16, column 25 in course.ftl. The problematic instruction: ---------- ==> ${student.course.courseName!} [on line 16, column 23 in course.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression student.course is undefined on line 16, column 25 in course.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125) at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135) at freemarker.core.Dot._getAsTemplateModel(Dot.java:78) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.DefaultToExpression._getAsTemplateModel(DefaultToExpression.java:100) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:259) at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:142) at com.you.test.freemarker.FreemarkerTest.testCourse(FreemarkerTest.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
2、错误原因
课程:${student.course!} 课程名:${student.course.courseName!}
${student.course}为空,可以在其后添加“!”判断,但是${student.course.courseName} 空值后再判断空值是不能这样加“!”,${student.course.courseName!}
3、解决办法
课程:${student.course!} 课程名:${(student.course.courseName)!"无任何值"}
运行结果:
课程: 课程名:无任何值
freemarker报错之六的更多相关文章
- freemarker报错之四
1.错误描述 五月 28, 2014 9:56:48 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proce ...
- freemarker报错之七
1.错误描述 五月 30, 2014 11:33:57 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...
- 关于SpringMVC整合freemarker报错问题
错误信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FreeMa ...
- freemarker报错之三
1.错误描写叙述 Expression students is undefined on line 30, column 24 in student.ftl. The problematic inst ...
- freemarker报错之八
1.错误描写叙述 freemarker.core.ParseException: Encountered "string" at line 21, column 21 in typ ...
- freemarker报错之二
1.错误描述 五月 27, 2014 12:07:05 上午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...
- freemarker报错之一
freemarker 1.错误描述 java.io.FileNotFoundException: Template user.ftl not found. at freemarker.template ...
- freemarker报错之五
1.错误描述 freemarker.core.ParseException: Token manager error: freemarker.core.TokenMgrError: Lexical e ...
- freemarker报错之十五
1.错误描述 六月 04, 2014 11:04:03 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...
随机推荐
- Django的admin.py注册流程
通常创建一个Django项目的时候,在Django的配置文件settings.py中,都会有下面的这段配置: INSTALLED_APPS = [ 'django.contrib.admin', 'd ...
- HTML基础知识概括
1.html的概念 HTML是用来描述网页的一种语言. HTML指的是超文本标记语言(HyperText Markup Language) HTML不是一种编程语言,而是一种标记语言(markup l ...
- 使用Google Cloud Platform构建机器学习项目-宠物识别
宠物识别我们使用到了tensorflow object-detection API (https://github.com/tensorflow/models/tree/master/researc ...
- AndroidStudio3更改包名失败
使用Android Studio 3.0 Beta6更改包名refactor---rename一直提示:Refactoring cannot be performedFile xxx\build\xx ...
- 【Tomcat】Tomcat的使用
第一章 JDK的安装 1.1 windows下安装 1.1.1 配置环境变量 安装完成后,还要进行 Java 环境的配置,才能正常使用,步骤如下: (1)在我的电脑点击右键——〉选择属性, (2) ...
- 洛谷 [P4011] 孤岛营救问题
状压+BFS 通过观察数据范围可知,我们应该状压钥匙种类,直接BFS即可 注意,一个点处可能不知有一把钥匙 #include <iostream> #include <cstdio& ...
- 夏令营提高班上午上机测试 Day 1 解题报告
Day 1的题难度上来说不算太高,但是T2和T3还是有一定的思维量的. 一个比较好的开始.虽然AK的人只有几个.. (懒得去翻result了..忘了当时拿了多少分了 (哦,前两天我们机房是没有成绩的, ...
- 深度学习(二)更新ing~
监督学习是指:利用一组已知类别的样本调整分类器的参数,使其达到所要求性能的过程,也称为监督训练或有教师学习 通俗来说就是人给过一个tag再来训练. 神经网络: 三个隐藏层的一个神经网络e.g 后面又提 ...
- arm 异常处理结构
概念:正常的程序执行过程中发生暂时的停止称为异常,如果发现异常情况,将会进行异常处理 作用:快速响应用户的行为,提高cpu的响应能力 异常类型: 异常处理的三个步骤: 1.保护现场: 工作模式保存:C ...
- php 数组变成树状型结构
<? php $stime = microtime(true); $nodes = [ ['id' = > 1, 'pid' = > 0, 'name' = > 'a'], [ ...