1、错误描述
假如你现在还在为自己的技术担忧,假如你现在想提升自己的工资,假如你想在职场上获得更多的话语权,假如你想顺利的度过35岁这个魔咒,假如你想体验BAT的工作环境,那么现在请我们一起开启提升技术之旅吧,详情请点击http://106.12.206.16:8080/qingruihappy/index.html
1 五月 27, 2014 12:07:05 上午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 2 严重: Template processing error: "Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-in with this date." 3 4 Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.or ?string(format) built-in with this date. 5 The problematic instruction: 6 ---------- 7 ==> ${student.studentBirthday} [on line 17, column 12 in student.ftl] 8 ---------- 9 10 Java backtrace for programmers: 11 ---------- 12 freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 13 at freemarker.core.Environment.formatDate(Environment.java:776) 14 at freemarker.core.Expression.getStringValue(Expression.java:105) 15 at freemarker.core.Expression.getStringValue(Expression.java:93) 16 at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 17 at freemarker.core.Environment.visit(Environment.java:221) 18 at freemarker.core.MixedContent.accept(MixedContent.java:92) 19 at freemarker.core.Environment.visit(Environment.java:221) 20 at freemarker.core.Environment.process(Environment.java:199) 21 at freemarker.template.Template.process(Template.java:259) 22 at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) 23 at com.you.test.freemarker.FreemarkerTest.student(FreemarkerTest.java:125) 24 at com.you.test.freemarker.FreemarkerTest.testStudent(FreemarkerTest.java:111) 25 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 26 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 27 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 28 at java.lang.reflect.Method.invoke(Unknown Source) 29 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 30 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 31 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 32 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 33 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 34 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) 35 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) 36 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 37 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 38 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 39 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 40 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 41 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 42 at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 43 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 44 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 45 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 46 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 47 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 48 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 49 50 51 Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 52 The problematic instruction: 53 ---------- 54 ==> ${student.studentBirthday} [on line 17, column 12 in student.ftl] 55 ---------- 56 57 Java backtrace for programmers: 58 ---------- 59 freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 60 at freemarker.core.Environment.formatDate(Environment.java:776) 61 at freemarker.core.Expression.getStringValue(Expression.java:105) 62 at freemarker.core.Expression.getStringValue(Expression.java:93) 63 at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 64 at freemarker.core.Environment.visit(Environment.java:221) 65 at freemarker.core.MixedContent.accept(MixedContent.java:92) 66 at freemarker.core.Environment.visit(Environment.java:221) 67 at freemarker.core.Environment.process(Environment.java:199) 68 at freemarker.template.Template.process(Template.java:259) 69 at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) 70 71 72 73 学生信息 74 75 76 77 78 79 80 81 82 83 姓名:张三丰 84 性别:男 85 年龄:34 86 生日: 87 Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.or ?string(format) built-in with this date. 88 The problematic instruction: 89 ---------- 90 ==> ${student.studentBirthday} [on line 17, column 12 in student.ftl] 91 ---------- 92 93 Java backtrace for programmers: 94 ---------- 95 freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 96 at freemarker.core.Environment.formatDate(Environment.java:776) 97 at freemarker.core.Expression.getStringValue(Expression.java:105) 98 at freemarker.core.Expression.getStringValue(Expression.java:93) 99 at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 100 at freemarker.core.Environment.visit(Environment.java:221) 101 at freemarker.core.MixedContent.accept(MixedContent.java:92) 102 at freemarker.core.Environment.visit(Environment.java:221) 103 at freemarker.core.Environment.process(Environment.java:199) 104 at freemarker.template.Template.process(Template.java:259) 105 at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) 106 at com.you.test.freemarker.FreemarkerTest.student(FreemarkerTest.java:125) 107 at com.you.test.freemarker.FreemarkerTest.testStudent(FreemarkerTest.java:111) 108 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 109 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 110 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 111 at java.lang.reflect.Method.invoke(Unknown Source) 112 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 113 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 114 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 115 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 116 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 117 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) 118 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) 119 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 120 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 121 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 122 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 123 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 124 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 125 at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 126 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 127 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 128 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 129 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 130 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 131 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 132 at com.you.test.freemarker.FreemarkerTest.student(FreemarkerTest.java:125) 133 at com.you.test.freemarker.FreemarkerTest.testStudent(FreemarkerTest.java:111) 134 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 135 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 136 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 137 at java.lang.reflect.Method.invoke(Unknown Source) 138 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 139 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 140 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 141 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 142 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 143 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) 144 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) 145 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 146 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 147 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 148 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 149 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 150 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 151 at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 152 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 153 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 154 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 155 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 156 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 157 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 158 五月 27, 2014 12:07:05 上午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 159 严重: Template processing error: "Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-in with this date." 160 161 Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 162 The problematic instruction: 163 ---------- 164 ==> ${student.studentBirthday} [on line 17, column 12 in student.ftl] 165 ---------- 166 167 Java backtrace for programmers: 168 ---------- 169 freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 170 at freemarker.core.Environment.formatDate(Environment.java:776) 171 at freemarker.core.Expression.getStringValue(Expression.java:105) 172 at freemarker.core.Expression.getStringValue(Expression.java:93) 173 at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 174 at freemarker.core.Environment.visit(Environment.java:221) 175 at freemarker.core.MixedContent.accept(MixedContent.java:92) 176 at freemarker.core.Environment.visit(Environment.java:221) 177 at freemarker.core.Environment.process(Environment.java:199) 178 at freemarker.template.Template.process(Template.java:259) 179 at com.you.freemarker.FreemarkerTemplate.printFile(FreemarkerTemplate.java:109) 180 at com.you.test.freemarker.FreemarkerTest.studentFile(FreemarkerTest.java:139) 181 at com.you.test.freemarker.FreemarkerTest.testStudent(FreemarkerTest.java:112) 182 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 183 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 184 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 185 at java.lang.reflect.Method.invoke(Unknown Source) 186 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 187 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 188 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 189 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 190 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 191 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) 192 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) 193 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 194 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 195 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 196 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 197 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 198 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 199 at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 200 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 201 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 202 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 203 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 204 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 205 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 206 207 208 Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 209 The problematic instruction: 210 ---------- 211 ==> ${student.studentBirthday} [on line 17, column 12 in student.ftl] 212 ---------- 213 214 Java backtrace for programmers: 215 ---------- 216 freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. 217 at freemarker.core.Environment.formatDate(Environment.java:776) 218 at freemarker.core.Expression.getStringValue(Expression.java:105) 219 at freemarker.core.Expression.getStringValue(Expression.java:93) 220 at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 221 at freemarker.core.Environment.visit(Environment.java:221) 222 at freemarker.core.MixedContent.accept(MixedContent.java:92) 223 at freemarker.core.Environment.visit(Environment.java:221) 224 at freemarker.core.Environment.process(Environment.java:199) 225 at freemarker.template.Template.process(Template.java:259) 226 at com.you.freemarker.FreemarkerTemplate.printFile(FreemarkerTemplate.java:109) 227 at com.you.test.freemarker.FreemarkerTest.studentFile(FreemarkerTest.java:139) 228 at com.you.test.freemarker.FreemarkerTest.testStudent(FreemarkerTest.java:112) 229 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 230 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 231 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 232 at java.lang.reflect.Method.invoke(Unknown Source) 233 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 234 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 235 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 236 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 237 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 238 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) 239 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) 240 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 241 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) 242 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 243 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) 244 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) 245 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) 246 at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 247 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 248 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 249 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 250 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 251 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 252 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
2、错误原因
不能将Date类型直接转化为String类型
3、解决办法
将日期类型后面添加如下:
原来:生日:${student.studentBirthday}
修改后:生日:${(student.studentBirthday)?string("yyyy-MM-dd")}